Wordpress.com Stats Disappear After New Theme Install
Written by sean on April 30, 2008 – 11:30 am -
Last week, when I installed the new theme for my site (Xplosive from BlogOhBlog), I noticed my stats in Wordpress.com Stats plugin dropped to 0. I thought this might just be a fluke, since every once in a while I will have a day where the visits are in the single digits. But by day two I was getting worried. Then I received a message from a friend using the Contact page and I knew something was up since it was still showing 0 hits.
I was still getting a page count via Google Analytics, but I love Wordpress.com Stats. The stats are (almost) real time, and it gives me just enough information for a quick over view of what has been going on. After some digging I found that this sometimes happens.
The fix is pretty easy, although it will require you to modify actual PHP pages (which is not that hard with the Wordpress Theme editor. I am assuming Wordpress 2.5 for this (although everything should work in earlier installations). Simply go to the Design Tab->Theme Editor. Now we will need to add the function in 3 places:
- Main Index Template (index.php) - At the bottom of the file, find the </body> tag. Add function (just paste what is in bold) <?php wp_footer(); ?> on a new line above it. Then press the update file button.
- Page Template (page.php) - At the bottom of the file, find the </body> tag. Add function (just paste what is in bold) <?php wp_footer(); ?> on a new line above it. Then press the update file button.
- Single Post (single.php) - At the bottom of the file, find the </body> tag. Add function (just paste what is in bold) <?php wp_footer(); ?> on a new line above it. Then press the update file button.
Now, I am not a PHP guru by any means, but what has happened is that the new theme did not include a call to the function that calculates your stats, so to the Stats program it looked like your stats had dropped to zero and nobody was visiting your blog.
My theme includes a footer function, and it may be that this is a better place to put it. The documentation I found said to put it on the main pages, but the footer function of the theme is included when a new page is loaded so that seems to me that it would work better. I’m going to go ahead an try it out, and hopefully I’ll be able to let you know before too long.
Tags: Blogging, stats, theme, wordpress, xplosive
Posted in Blogging, Tech, Tip, Web |
One Comment to “Wordpress.com Stats Disappear After New Theme Install”
Leave a Comment
You must be logged in to post a comment.










April 30th, 2008 at 12:00 pm
I’ve confirmed it. Adding the wp_footer function to the themes footer works fine and then you only need to add it in one place.