Myself, Coding, Ranting, and Madness

The Consciousness Stream Continues…

WordPress Jetpack: Don't Count Admin Views

7 Aug 2012 8:00 Tags: None

One of the annoyances that I have had with WordPress is that fact that the Stats module will count my page views which, when I'm trying to make something look how I want it to look, can exceed 100 in a day. This has pretty much entirely destroyed the meaning of my stats since moving from Blogger.

The bug has been open for the better part of 3 years, as far as I can tell from the other people complaining, and the bug reports on the website. The manual fix, however, was only two lines long.

In the file jetpack/modules/stats.php, there is a function that looks like: function stats_template_redirect() { global $wp_the_query, $current_user, $stats_footer; if ( is_feed() || is_robots() || is_trackback()) return; $options = stats_get_options(); If this is replaced with function stats_template_redirect() { global $wp_the_query, $current_user, $stats_footer; if ( is_feed() || is_robots() || is_trackback() || in_array('administrator', $current_user->roles)) return; $options = stats_get_options(); Then the plugin works as expected.

Be aware that this change will be reverted whenever JetPack is upgraded. Any may not work in future versions