Fixing your theme so that it works with WordPress.com Stats…


WordPress.com Stats is one of the most popular WordPress plugins.  I have tried using it in the past, but it never collected stats.  I never actually pursued a solution to this because I was using another stats plugin that was partially functional and able to give me most of the information I wanted. 

Today I spent a little time searching the WordPress support forums and found that my theme was missing a function call that the plugin relies on. 

Simply put, in your theme’s footer.php file, right above your </body> and </html> tags, you need to add:

<?php wp_footer(); ?>

And that’s all there is to it. You can be sure that this is safe to add because every theme is supposed to have this line. wp_footer() doesn’t generate any output so you shouldn’t see any changes to your site’s display.

If it still doesn’t work, be sure you are testing it while logged out. (You can always use another browser to save time.) It will not register hits from a logged in user. Failing that, if you’re using the WP-Super-Cache (as you should be) plugin, try clearing your cache.

, , ,

  1. #1 by Raju at December 29th, 2008

    Good one! Many of the plugins require wp_footer() function to be present in the footer to work properly.

    • #2 by clifgriffin at December 30th, 2008

      That’s true. Any plugin that tries to write to your footer probably shall fail.

(will not be published)