添加文章阅读次数插件:WP-PostViews 1.40详细用法


WordPress views 用来查看文章读取数的插件。由lesterchan开发。发表的文章只有回复数显示,谁都知道很多人是潜水的,看文章从来不回复,那么我想知道有多少人看过我的文章怎么办呢? WordPress自身没有这个功能,只好借助于一款强大的插件:PostViews,目前最新的版本是1.40。

跟其他的所有插件一样,只需要将解压后的文件夹整个上传至/wp-content/plugins/下面,然后再将其激活就算安装成功。

General Usage
  1. Open wp-content/themes/<YOUR THEME NAME>/index.phpYou may place it in single.php, post.php or page.php also.
  2. Find:
    <?php while (have_posts()) : the_post(); ?>
  3. Add Anywhere Below It:
    <?php if(function_exists('the_views')) { the_views(); } ?>
  4. Go to ‘WP-Admin -> Settings -> Post Views’ to configure the plugin.
View Stats (With Widgets)
  1. Activate WP-PostViews Widget Plugin
  2. Go to ‘WP-Admin -> Appearance -> Widgets
  3. To Display Most Viewed Post
  4. You can add the Most Viewed Widget by clicking on the ‘Add’ link besides it.
  5. After adding, you can configure the Most Viewed Widget by clicking on the ‘Edit’ link besides it.
  6. Click ‘Save Changes’
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 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:

    http://yoursite.com/?v_sortby=views&v_orderby=desc

    You can replace desc with asc if you want the least viewed posts.


18条回应:“添加文章阅读次数插件:WP-PostViews 1.40详细用法”

  1. 9…

    rocking…Yes, the post is very interesting and I really like.It contains many interesting information and i have learned a lot from you .jessonlin/comment/2011nov…

  2. 4…

    “BanXie” is the ground type of board type shoes. It comes from the skateboard people wear shoes, so also called skateboarding shoes. BanXie compared with general shoes, different place is: it is almost a flat bottom, easy to let feet are able to comp…

  3. To every person whom know what you are, My partner and i wish to say that you all maintain really expensive areas inside my heart. We look into anyone please remember gorgeous along with excitement instances.liulipingcomment201203blog

  4. cn84rtxw4dcwn4xnc4rwif

    […]although websites we backlink to below are considerably not associated to ours, we feel they’re truly worth a go by means of, so have a look[…]