Title: WP-PostViews
Author: Lester Chan
Published: <strong>2 сар 8, 2006</strong>
Last modified: 8 сар 31, 2025

---

Search plugins

![](https://ps.w.org/wp-postviews/assets/banner-772x250.jpg?rev=1206762)

![](https://ps.w.org/wp-postviews/assets/icon.svg?rev=978002)

# WP-PostViews

 By [Lester Chan](https://profiles.wordpress.org/gamerz/)

[Download](https://downloads.wordpress.org/plugin/wp-postviews.1.78.zip)

 * [Details](https://mn.wordpress.org/plugins/wp-postviews/#description)
 * [Reviews](https://mn.wordpress.org/plugins/wp-postviews/#reviews)
 * [Development](https://mn.wordpress.org/plugins/wp-postviews/#developers)

 [Support](https://wordpress.org/support/plugin/wp-postviews/)

## Description

### Usage

 1. Open `wp-content/themes/<YOUR THEME NAME>/index.php`
 2. You may place it in archive.php, single.php, post.php or page.php also.
 3. Find: `<?php while (have_posts()) : the_post(); ?>`
 4. Add Anywhere Below It (The Place You Want The Views To Show): `<?php if(function_exists('
    the_views')) { the_views(); } ?>`
 5. Or you can use the shortcode `[views]` or `[views id="1"]` (where 1 is the post
    ID) in a post
 6. Go to `WP-Admin -> Settings -> PostViews` to configure the plugin.

### Development

[https://github.com/lesterchan/wp-postviews/](https://github.com/lesterchan/wp-postviews/)

### Translations

[http://dev.wp-plugins.org/browser/wp-postviews/i18n/](http://dev.wp-plugins.org/browser/wp-postviews/i18n/)

### Credits

 * Plugin icon by [Iconmoon](http://www.icomoon.io) from [Flaticon](http://www.flaticon.com)

### Donations

I spent most of my free time creating, updating, maintaining and supporting these
plugins, if you really love my plugins and could spare me a couple of bucks, I will
really appreciate it. If not feel free to use it without any obligations.

### Version 1.76.1

 * NEW: Add Post Author in views template
 * NEW: Bump for WordPress 5.3

### Version 1.76

 * NEW: Added postviews_should_count filter
 * FIXED: Change to (int) from intval() and use sanitize_key() with it.

### Version 1.75

 * NEW: Use WP_Query() for most/least viewed posts

### Version 1.74

 * NEW: Bump WordPress 4.7
 * NEW: Template variable %POST_CATEGORY_ID%. It returns Post’s Category ID. If 
   you are using Yoast SEO Plugin, it will return the priority Category ID. Props
   @FunFrog-BY

### Version 1.73

 * FIXED: In preview mode, don’t count views

### Version 1.72

 * NEW: Add %POST_THUMBNAIL% to template variables

### Version 1.71

 * FIXED: Notices in Widget Constructor for WordPress 4.3

### Version 1.70

 * FIXED: Integration with WP-Stats

### Version 1.69

 * NEW: Shortcode `[views]` or [views id=”POST_ID”]` to embed view count into post
 * NEW: Added template variable `%VIEW_COUNT_ROUNDED%` to support rounded view count
   like 10.1k or 11.2M

### Version 1.68

 * NEW: Added action hook ‘postviews_increment_views’ and ‘postviews_increment_views_ajax’
 * NEW: Allow custom post type to be chosen under the widget

### Version 1.67

 * NEW: Allow user to not use AJAX to update the views even though WP_CACHE is true

### Version 1.66

 * NEW: Supports MultiSite Network Activation
 * NEW: Add %POST_DATE% and %POST_TIME% to template variables
 * NEW: Add China isearch engines bots
 * NEW: Ability to pass in an array of post types for get_most/least_*() functions.
   Props Leo Plaw.
 * FIXED: Moved uninstall to uninstall.php and hence fix missing nonce. Props Julio
   Potier.
 * FIXED: Notices and better way to get views from meta. Props daankortenbach.
 * FIXED: No longer needing add_post_meta() if update_post_meta() fails.

### Version 1.65 (02-06-2013)

 * FIXED: Views not showing in WP-Admin if “Display Options” is not set to “Display
   to everyone”

## Screenshots

 * [[
 * PostViews
 * [[
 * Admin – PostViews Options

## FAQ

### How To View Stats With Widgets?

 * Go to `WP-Admin -> Appearance -> Widgets`
 * The widget name is Views.

### To Display Least Viewed Posts

    ```
    <?php if (function_exists('get_least_viewed')): ?>
        <ul>
            <?php get_least_viewed(); ?>
        </ul>
    <?php endif; ?>
    ```

 * The first value you pass in is the post type that you want. If you want to get
   every post types, just use ‘both’. It also supports PHP array: example `array('
   post', 'page')`.
 * 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

    ```
    <?php if (function_exists('get_most_viewed')): ?>
        <ul>
            <?php get_most_viewed(); ?>
        </ul>
    <?php endif; ?>
    ```

 * The first value you pass in is the post type that you want. If you want to get
   every post types, just use ‘both’. It also supports PHP array: example `array('
   post', 'page')`.
 * 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

    ```
    <?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 the post type that you want. If you want to get
   every post types, just use ‘both’. It also supports PHP array: example `array('
   post', 'page')`.
 * 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

    ```
    <?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 the post type that you want. If you want to get
   every post types, just use ‘both’. It also supports PHP array: example `array('
   post', 'page')`.
 * 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

    ```
    <?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 the post type that you want. If you want to get
   every post types, just use ‘both’. It also supports PHP array: example `array('
   post', 'page')`.
 * 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

    ```
    <?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 the post type that you want. If you want to get
   every post types, just use ‘both’. It also supports PHP array: example `array('
   post', 'page')`.
 * 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( array( 'meta_key' => 'views', 'orderby' => '
   meta_value_num', 'order' => '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.

### To Display Updating View Count With LiteSpeed Cache

Use: `<div id="postviews_lscwp"></div>` to replace `<?php if(function_exists('the_views')){
the_views(); } ?>`.
 NOTE: The id can be changed, but the div id and the ajax function
must match. Replace the ajax query in `wp-content/plugins/wp-postviews/postviews-
cache.js` with

    ```
    jQuery.ajax({
        type:"GET",
        url:viewsCacheL10n.admin_ajax_url,
        data:"postviews_id="+viewsCacheL10n.post_id+"&action=postviews",
        cache:!1,
        success:function(data) {
            if(data) {
                jQuery('#postviews_lscwp').html(data+' views');
            }
       }
    });
    ```

Purge the cache to use the updated pages.

### To Get Views With REST API

You can obtain the number of post views by adding `views` to your `_fields` parameter:
/
wp/v2/posts?_fields=views,title

## Reviews

![](https://secure.gravatar.com/avatar/a6bd2ffefeab19f6b63b4bf213036879c37c226bc6dc43b32bd1aefd63fa3cf1?
s=60&d=retro&r=g)

### 󠀁[Useful plugin, but unique view counting by IP would be a great addition](https://wordpress.org/support/topic/useful-plugin-but-unique-view-counting-by-ip-would-be-a-great-addition/)󠁿

 [KR. Laboratories](https://profiles.wordpress.org/krashlab/) 10 сар 21, 2025

I’ve been using WP-PostViews for some time now, and it’s a very straightforward 
and effective plugin for displaying post views. The settings to count views only
from guests and exclude bots work well. However, I’ve noticed that if a guest refreshes
a page multiple times, each refresh is counted as a new view. While this is typical
behavior for a basic hit counter, it makes the view count less representative of
actual unique visitors. I would highly recommend considering an enhancement to include
an option to count unique views based on IP address (e.g., once per IP within a 
specified timeframe like 24 hours). This would significantly improve the accuracy
of the statistics and make the plugin even more valuable for site owners who want
to track genuine reader engagement. Thank you for this plugin!

![](https://secure.gravatar.com/avatar/eb107a34064b50d8474267f0f6868340edb106916e0836fa110e0d9b82f13e62?
s=60&d=retro&r=g)

### 󠀁[No longer works with Advanced Queries / Elementor](https://wordpress.org/support/topic/no-longer-works-with-advanced-queries-elementor/)󠁿

 [whitelabelcroydon](https://profiles.wordpress.org/whitelabelcroydon/) 4 сар 26,
2024

Have been using this a while along side Advanced Queries and Elementors Loop widget
to display a list grid of most popular articles on a website. Doesnt seem to be 
working anymore. I think its still keeping count of the post views, but the views
template variable isnt pulling in the correct posts. From the posts it is showing
it looked like it stopped updating in January of this year. Will need to find another
solution!

![](https://secure.gravatar.com/avatar/d366ac4ddbadeab9be721eaf762279e0e5d3f19b1d60f5424926013d59437780?
s=60&d=retro&r=g)

### 󠀁[It doesn’t work with 6.5.2 wordpres version](https://wordpress.org/support/topic/it-doesnt-work-with-6-5-2-wordpres-version/)󠁿

 [sergio.pinna.prato](https://profiles.wordpress.org/sergiopinnaprato/) 4 сар 21,
2024

It doesn’t work with 6.5.2 wordpres version.

![](https://secure.gravatar.com/avatar/e5f7b48fc5828047a785177445d5c23bd60340bd984b3cf46010f3bb441b3612?
s=60&d=retro&r=g)

### 󠀁[I guess this is no longer in supported](https://wordpress.org/support/topic/i-guess-this-is-no-longer-in-supported/)󠁿

 [Beulahland83](https://profiles.wordpress.org/beulahland83/) 1 сар 8, 2023

The plugin is no longer compatible with some themes example of (Corpo)

![](https://secure.gravatar.com/avatar/c017a834db5513b02da7e23515932225d4ff9d4441cd99291e92beff20e01058?
s=60&d=retro&r=g)

### 󠀁[very useful](https://wordpress.org/support/topic/very-useful-2967/)󠁿

 [douggeeks](https://profiles.wordpress.org/douggeeks/) 3 сар 23, 2022

Very useful little plugin.

![](https://secure.gravatar.com/avatar/277e3a55b0061c5b136b04acb20de33371ab3a0b23024de671d12570ddce961e?
s=60&d=retro&r=g)

### 󠀁[Awesome](https://wordpress.org/support/topic/awesome-9173/)󠁿

 [Ahmed Faruk](https://profiles.wordpress.org/ahmedfaruk/) 12 сар 6, 2021

This is the Plugin that I was looking for. Thanks a lot!

 [ Read all 65 reviews ](https://wordpress.org/support/plugin/wp-postviews/reviews/)

## Contributors & Developers

“WP-PostViews” is open source software. The following people have contributed to
this plugin.

Contributors

 *   [ Lester Chan ](https://profiles.wordpress.org/gamerz/)

“WP-PostViews” has been translated into 18 locales. Thank you to [the translators](https://translate.wordpress.org/projects/wp-plugins/wp-postviews/contributors)
for their contributions.

[Translate “WP-PostViews” into your language.](https://translate.wordpress.org/projects/wp-plugins/wp-postviews)

### Interested in development?

[Browse the code](https://plugins.trac.wordpress.org/browser/wp-postviews/), check
out the [SVN repository](https://plugins.svn.wordpress.org/wp-postviews/), or subscribe
to the [development log](https://plugins.trac.wordpress.org/log/wp-postviews/) by
[RSS](https://plugins.trac.wordpress.org/log/wp-postviews/?limit=100&mode=stop_on_copy&format=rss).

## Changelog

### Version 1.78

 * NEW: Add %POST_THUMBNAIL_URL% to template variables

### Version 1.77

 * NEW: Use Vanilla JS. Props @JiveDig
 * NEW: Bump to WordPress 6.2
 * NEW: Support views under fields for Rest API. Props @vitro-mod

## Meta

 *  Version **1.78**
 *  Last updated **7 сар ago**
 *  Active installations **100,000+**
 *  WordPress version ** 4.0 or higher **
 *  Tested up to **6.8.5**
 *  Languages
 * [Catalan](https://ca.wordpress.org/plugins/wp-postviews/), [Chinese (China)](https://cn.wordpress.org/plugins/wp-postviews/),
   [Chinese (Taiwan)](https://tw.wordpress.org/plugins/wp-postviews/), [Dutch](https://nl.wordpress.org/plugins/wp-postviews/),
   [English (UK)](https://en-gb.wordpress.org/plugins/wp-postviews/), [English (US)](https://wordpress.org/plugins/wp-postviews/),
   [French (France)](https://fr.wordpress.org/plugins/wp-postviews/), [Galician](https://gl.wordpress.org/plugins/wp-postviews/),
   [Greek](https://el.wordpress.org/plugins/wp-postviews/), [Japanese](https://ja.wordpress.org/plugins/wp-postviews/),
   [Persian](https://fa.wordpress.org/plugins/wp-postviews/), [Russian](https://ru.wordpress.org/plugins/wp-postviews/),
   [Spanish (Chile)](https://cl.wordpress.org/plugins/wp-postviews/), [Spanish (Spain)](https://es.wordpress.org/plugins/wp-postviews/),
   [Spanish (Venezuela)](https://ve.wordpress.org/plugins/wp-postviews/), [Swedish](https://sv.wordpress.org/plugins/wp-postviews/),
   [Tibetan](https://bo.wordpress.org/plugins/wp-postviews/), [Ukrainian](https://uk.wordpress.org/plugins/wp-postviews/),
   [Vietnamese](https://vi.wordpress.org/plugins/wp-postviews/).
 *  [Translate into your language](https://translate.wordpress.org/projects/wp-plugins/wp-postviews)
 * Tags
 * [Counter](https://mn.wordpress.org/plugins/tags/counter/)[hits](https://mn.wordpress.org/plugins/tags/hits/)
   [postviews](https://mn.wordpress.org/plugins/tags/postviews/)[views](https://mn.wordpress.org/plugins/tags/views/)
 *  [Advanced View](https://mn.wordpress.org/plugins/wp-postviews/advanced/)

## Ratings

 4.4 out of 5 stars.

 *  [  48 5-star reviews     ](https://wordpress.org/support/plugin/wp-postviews/reviews/?filter=5)
 *  [  8 4-star reviews     ](https://wordpress.org/support/plugin/wp-postviews/reviews/?filter=4)
 *  [  1 3-star review     ](https://wordpress.org/support/plugin/wp-postviews/reviews/?filter=3)
 *  [  1 2-star review     ](https://wordpress.org/support/plugin/wp-postviews/reviews/?filter=2)
 *  [  7 1-star reviews     ](https://wordpress.org/support/plugin/wp-postviews/reviews/?filter=1)

[Add my review](https://wordpress.org/support/plugin/wp-postviews/reviews/#new-post)

[See all reviews](https://wordpress.org/support/plugin/wp-postviews/reviews/)

## Contributors

 *   [ Lester Chan ](https://profiles.wordpress.org/gamerz/)

## Support

Got something to say? Need help?

 [View support forum](https://wordpress.org/support/plugin/wp-postviews/)

## Donate

Would you like to support the advancement of this plugin?

 [ Donate to this plugin ](https://lesterchan.net/site/donation/)