WordPress.org

Ready to get started?Download WordPress

Plugin Directory

WordPress Stats View Counter

Saves view counts from WordPress.com Stats Jetpack module as post meta data.

Which post meta key is used?

By default views is the key where the view counts are saved, but you can filter this with the filter view_counter_meta_key. So for example, if you wanted to change the meta key from views to my-key, you would use this in your functions.php file:

add_filter( 'view_counter_meta_key', 'my_view_counter_meta_key', 10, 1 );

function my_view_counter_meta_key( $key ) {

    return 'my-key';

}

The plugin will check to make sure the new view count is greater than the old one before replacing, so there is some fallback to prevent it from overwriting previously saved views from other plugins also using the views post meta key.

How do I display the views?

Either using get_post_meta( $post->ID, 'views', true ); or the shortcode [view-count].

The shortcode can also accept before and after parameters, like so:

[view-count before="Views: "]
[view-count after=" views"]

How often does it update the views?

Every 3 hours an entry is accessed, the plugin will check the WordPress.com Stats view count and update locally. The delay is to ensure we don't overload the WordPress.com Stats API.

This will be unnoticeable to the average visitor because it's unlikely they are sitting on your site waiting for the views to update, like you might be.

Unless you have an extremely active site, there isn't really much reason for the check to be more frequent.

Can I change the update time?

Yes, if you really want to, you can! Use the following filter:

add_filter( 'view_counter_transient_expiration', 'my_view_counter_transient_expiration', 10, 1 );

function my_view_counter_transient_expiration( $hours ) {

    return 2; // time in hours

}

Requires: 3.0 or higher
Compatible up to: 3.9.1
Last Updated: 2014-4-18
Downloads: 15,896

Ratings

5 stars
5 out of 5 stars

Support

0 of 1 support threads in the last two months have been resolved.

Got something to say? Need help?

Compatibility

+
=
Not enough data

0 people say it works.
0 people say it's broken.

50,2,1
100,2,2