Track & Show post views without plugin

This simple snippet tracks and shows post views in your templates – and without the need for a plugin.

Instructions
Add this to your functions.php file.

Add this to your single.php, and make sure you paste in inside the loop.

To display the number of views a post has, just add this in your template where you want the post view count to be displayed.

Related Links:
http://wpsnipp.com/index.php/functions-php/track-post-views-without-a-plugin-using-post-meta/

Comments

8 Replies to “Track & Show post views without plugin”

  1. this works but i noticed and issue. When i shared a post on Facebook etc… many people click on the shared post. however I noticed that the view count do not change. Its only change if you click on the post on the site only. Please help. Thanks

Leave a Reply

Your email address will not be published. Required fields are marked *

Snippet Info

Tested with Wordpress v. NA

Track & Show post views without plugin
4.8 (96%) 65 votes
Please report broken snippets.
Report Broken Snippet