How to Display Post Views Using WP Statistics Plugin (WordPress)

WP Statistics is a comprehensive plugin for your WordPress visitor statistics. If you install this plugin, the number post views is also displayed next to each post. If you want to add a post views counter, you will need to install a separate plugin or create a function. However, it will be a good idea to use the post views data created by WP Statistics. If you can retrieve the post count (which is referred to as "Hits" in WP Statistics), you do not need to install an extra plugin.

I tried to find out where the post views data ("Hits") were saved in the database, but I couldn't. Instead, I noticed that the WP Statistics provides a function to do this. You can use the following function provided by this plugin.

WP Statistics

You can find the function wp_statistics_pages( 'total', "", $post_id ) in the file "wp-statistics.php." You can easily display post views for each post with this function.

Leave a Comment