How to track & show WordPress post views without a plugin

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

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:


16 Replies to “How to track & show WordPress post views without a 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

  2. Thanks a lot. The code snippet really worked like charm! It’s showing page views accordingly and very fast in updating the views too

Leave a Reply

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

Siteground Web Hosting