- Open wp-content/themes/<YOUR THEME NAME>/index.php You may place it in archive.php, single.php, post.php or page.php also.
- Find:
<?php while (have_posts()) : the_post(); ?>
- Add Anywhere Below It:
<?php if(function_exists('the_views')) { the_views(); } ?>
- Go to 'WP-Admin -> Settings -> PostViews' to configure the plugin.
View Stats (With Widgets)
- Go to 'WP-Admin -> Appearance -> Widgets'
- The widget name is Views.
View Stats (Outside WP Loop)
- To Display Least Viewed Posts
- Use:
<?php if (function_exists('get_least_viewed')): ?>
<ul>
<?php get_least_viewed(); ?>
</ul>
<?php endif; ?>
The first value you pass in is what you want to get, 'post', 'page' or 'both'.
The second value you pass in is the maximum number of post you want to get.
Default: get_least_viewed('both', 10);
- To Display Most Viewed Posts
- Use:
<?php if (function_exists('get_most_viewed')): ?>
<ul>
<?php get_most_viewed(); ?>
</ul>
<?php endif; ?>
The first value you pass in is what you want to get, 'post', 'page' or 'both'.
The second value you pass in is the maximum number of post you want to get.
Default: get_most_viewed('both', 10);
- To Display Least Viewed Posts By Tag
- Use:
<?php if (function_exists('get_least_viewed_tag')): ?>
<ul>
<?php get_least_viewed_tag(); ?>
</ul>
<?php endif; ?>
The first value you pass in is the tag id.
The second value you pass in is what you want to get, 'post', 'page' or 'both'.
The third value you pass in is the maximum number of post you want to get.
Default: get_least_viewed_tag(1, 'both', 10);
- To Display Most Viewed Posts By Tag
- Use:
<?php if (function_exists('get_most_viewed_tag')): ?>
<ul>
<?php get_most_viewed_tag(); ?>
</ul>
<?php endif; ?>
The first value you pass in is the tag id.
The second value you pass in is what you want to get, 'post', 'page' or 'both'.
The third value you pass in is the maximum number of post you want to get.
Default: get_most_viewed_tag(1, 'both', 10);
- To Display Least Viewed Posts For A Category
- Use:
<?php if (function_exists('get_least_viewed_category')): ?>
<ul>
<?php get_least_viewed_category(); ?>
</ul>
<?php endif; ?>
The first value you pass in is the category id.
The second value you pass in is what you want to get, 'post', 'page' or 'both'.
The third value you pass in is the maximum number of post you want to get.
Default: get_least_viewed_category(1, 'both', 10);
- To Display Most Viewed Posts For A Category
- Use:
<?php if (function_exists('get_most_viewed_category')): ?>
<ul>
<?php get_most_viewed_category(); ?>
</ul>
<?php endif; ?>
The first value you pass in is the category id.
The second value you pass in is what you want to get, 'post', 'page' or 'both'.
The third value you pass in is the maximum number of post you want to get.
Default: get_most_viewed_category(1, 'both', 10);
- To Sort Most/Least Viewed Posts
- You can use:
<?php query_posts('v_sortby=views&v_orderby=desc') ?>
Or pass in the variables to the URL:
You can replace desc with asc if you want the least viewed posts.