Visitor Counter for WordPress (Hit Counter)

You often wanted to show a hit counter for your WordPress site. There are a lot of plugins to solve this issue. But why are you making your site slower? Never use a plugin, if it’s really not needed.
Avoid plugins if you can do it yourself by a small code snippet. Here is how to add a visitor counter for WordPress.

Create a visitor counter

Step-1:
Open your functions.php file with an editor. Add the code below then save it.

Step-2:
Add following code to single.php

Step-3:
This is the final step. Decide where do you want to show the hit counter. Place this code into your template. It’s a good idea to show his counter in the footer area. But, choice is yours.

You’re done. Visit your site, it’ll show hit counter. Keep counting your visitors.

Need help with your WordPress tasks?

  • Shanmuga Sundaram

    this is hit count not visitor count. !

  • Hi, thanks for this … how about an additional update on perhaps using ajax call for when using a caching plugin? 🙂