Title: [Plugin: hitcounter] Double Count
Last modified: August 19, 2016

---

# [Plugin: hitcounter] Double Count

 *  [DigitalAlias](https://wordpress.org/support/users/digitalalias/)
 * (@digitalalias)
 * [16 years ago](https://wordpress.org/support/topic/plugin-hitcounter-double-count/)
 * I just installed hitcounter today. Very neat feature, I like it’s simiplicity.
   I noticed though, that the count increments are done in 2’s instead of 1. Any
   page I visit will show that it’s been seen twice.
 * [http://www.fergytech.com](http://www.fergytech.com)
 * [http://wordpress.org/extend/plugins/hitcounter/](http://wordpress.org/extend/plugins/hitcounter/)

Viewing 15 replies - 1 through 15 (of 16 total)

1 [2](https://wordpress.org/support/topic/plugin-hitcounter-double-count/page/2/?output_format=md)
[→](https://wordpress.org/support/topic/plugin-hitcounter-double-count/page/2/?output_format=md)

 *  [deadlyhifi](https://wordpress.org/support/users/tomdebruin/)
 * (@tomdebruin)
 * [16 years ago](https://wordpress.org/support/topic/plugin-hitcounter-double-count/#post-1516156)
 * Hi DigitalAlias,
 * the plugin works by adding 1 to the view count in the database when `the_content()`
   is called on a single page ( `is_single()` ). All I can think of right now is
   that `the_content()` is called more than once, somehow, on your page.
 * Could you post your single.php on [http://pastebin.com/](http://pastebin.com/)
   or some service like that so I could have a look.
 * I’ll just do a bit more research into adding filters on the_content as well.
 *  [deadlyhifi](https://wordpress.org/support/users/tomdebruin/)
 * (@tomdebruin)
 * [16 years ago](https://wordpress.org/support/topic/plugin-hitcounter-double-count/#post-1516174)
 * I figured out the problem. If `the_excerpt()` is displayed on the page as well
   as the `the_content()` the code runs twice since they are both returning `$content`.
 * I’ve just trying to figure out how to make it act only on full content…
 *  [deadlyhifi](https://wordpress.org/support/users/tomdebruin/)
 * (@tomdebruin)
 * [16 years ago](https://wordpress.org/support/topic/plugin-hitcounter-double-count/#post-1516180)
 * I’ve come up with a fix for this by offering an option on the settings page.
 * Version 1.2 will be with you shortly. Just a bit more testing to do.
 *  Thread Starter [DigitalAlias](https://wordpress.org/support/users/digitalalias/)
 * (@digitalalias)
 * [16 years ago](https://wordpress.org/support/topic/plugin-hitcounter-double-count/#post-1516322)
 * Very cool. Thanks for looking into this. In the “settings” page is there an option
   to reset the count – either by page or the entire site?
 *  [deadlyhifi](https://wordpress.org/support/users/tomdebruin/)
 * (@tomdebruin)
 * [16 years ago](https://wordpress.org/support/topic/plugin-hitcounter-double-count/#post-1516331)
 * There isn’t. I’ll add it to the “things to do” list.
 * Perhaps have the reset post count on the post edit page itself, and a reset entire
   site in the setting page (with an “are you sure?” check)?
 * I’ll have a think about it.
 *  [TadeuszD](https://wordpress.org/support/users/tadeuszd/)
 * (@tadeuszd)
 * [15 years, 12 months ago](https://wordpress.org/support/topic/plugin-hitcounter-double-count/#post-1516351)
 * Hi, Tom,
    I just downloaded and installed your plugin. The plugin is very nice,
   simple and consumes a little resources. It is exactly, what I need! 🙂
 * But I encountered the simple problem. The plugin don’t work with newest version
   of mySQL. In the ‘CREATE TABLE’ command you declare fields as ‘NOT NULL’, but
   function logCount don’t fill all corresponding fields. I correct this error by
   adding ‘DEFAUL 0’ to fields declaration.
    Can you correct this problem in official
   version of your plugin?
 *  [TadeuszD](https://wordpress.org/support/users/tadeuszd/)
 * (@tadeuszd)
 * [15 years, 12 months ago](https://wordpress.org/support/topic/plugin-hitcounter-double-count/#post-1516352)
 * Hi, once again…
    I’ve detected, that your plugin is gathering data for all posts,
   including deleted posts and revisions…
 * I now, this is only theoretical problem. But I think, the option “Reset all counters”,
   by deleting all rows from hitcounter table, will be very usefull in this situation.
   🙂
 *  [deadlyhifi](https://wordpress.org/support/users/tomdebruin/)
 * (@tomdebruin)
 * [15 years, 12 months ago](https://wordpress.org/support/topic/plugin-hitcounter-double-count/#post-1516357)
 * Hi TadeuszD, thanks for your feedback. You’re right about the DEFAULT 0 value.
   That’s easily sorted.
 * Deleting view count: I’ve been thinking about this. If I have the reset button
   within the post edit page it needs to not refresh the page when clicked (and 
   lose any changes you’ve made that havent saved) so I need to get my head around
   using AJAX in plugins. It doesn’t look too complex but I need to have a mess 
   around with it.
 * Regarding the ‘theoretical problem’. Are you saying that if you look at a deleted
   post, or a post revision, it counts as a view? I could do a check on post_status
   but it would require another database lookup.
 * Hitcounter was never meant to be the be all and end all in viewing statistics.
   It was just to act as a guide as to the popularity of a post.
    Do you think it’s
   worth doing .1 release to add the DEFAULT status (you’re the first to mention
   it) or wait until I figure out the AJAX thing?
 *  [TadeuszD](https://wordpress.org/support/users/tadeuszd/)
 * (@tadeuszd)
 * [15 years, 12 months ago](https://wordpress.org/support/topic/plugin-hitcounter-double-count/#post-1516358)
 * Hi,
    About ‘theoretical problem’ – I wil check it again… I’ve tested many modification
   and it may be my fault. 🙁 Please, don’t disturb yourself about this problem 
   at this time.
 * About ‘reset counters’ – The great advantage of your plugin is the siplicity.
   In my opinion using AJAX for reset counters is like “using the cannon to kill
   the mosquito” (this is the polish idiom).
 * I’m thinking now… Reset counters option is only needed if we are generating many‘
   false-views’ itself, while preparing and correcting posts. Instead of ‘reset’
   option, you can add option which means “ignore users with security level greater
   than…”. This option will allow us to ignore our (admins or redactors) activity.
   What do you think about it?
 *  Thread Starter [DigitalAlias](https://wordpress.org/support/users/digitalalias/)
 * (@digitalalias)
 * [15 years, 11 months ago](https://wordpress.org/support/topic/plugin-hitcounter-double-count/#post-1516367)
 * Hi tomdebruin,
 * I’m having a problem. The counter doesn’t seem to work anymore. Well; it doesn’t
   work when I check (enable) “Act on the_excerpt(); only” option. When I uncheck
   it, the counter works, but does doubles. When I check the option nothing is getting
   captured.
 * [http://www.fergytech.com](http://www.fergytech.com)
 *  [deadlyhifi](https://wordpress.org/support/users/tomdebruin/)
 * (@tomdebruin)
 * [15 years, 11 months ago](https://wordpress.org/support/topic/plugin-hitcounter-double-count/#post-1516375)
 * Hi DigitalAlias, could you post your single.php code on [http://pastebin.com/](http://pastebin.com/)
   or some service like that so I could have a look?
 *  [blueboxed](https://wordpress.org/support/users/blueboxed/)
 * (@blueboxed)
 * [15 years, 4 months ago](https://wordpress.org/support/topic/plugin-hitcounter-double-count/#post-1516405)
 * I am too receiving double counts. If you could help me out I would greatly appreciate
   it! I have enabled the option for ignoring admin users, and when checking on 
   a different computer, not logged into the site, I still receive double counts.
 * [http://pastebin.com/Ww1F8r97](http://pastebin.com/Ww1F8r97)
 *  [deadlyhifi](https://wordpress.org/support/users/tomdebruin/)
 * (@tomdebruin)
 * [15 years, 4 months ago](https://wordpress.org/support/topic/plugin-hitcounter-double-count/#post-1516406)
 * Hi blueboxed,
 * I just used your code on a site and I’m just getting one count increment. Are
   you using the latest version of the plugin?
 *  [blueboxed](https://wordpress.org/support/users/blueboxed/)
 * (@blueboxed)
 * [15 years, 4 months ago](https://wordpress.org/support/topic/plugin-hitcounter-double-count/#post-1516407)
 * Hmm thats odd. I just installed the plugin yesterday, so it’s up to date. The
   site is leakplay[] com. Im wasn’t sure if it had something to do with the excerpt
   being called or not, so I’ve tested the placement of the count code & it counts
   by two regardless of where I put the code (widget, footer, etc).
 * Thanks for your quick response!
 *  [deadlyhifi](https://wordpress.org/support/users/tomdebruin/)
 * (@tomdebruin)
 * [15 years, 3 months ago](https://wordpress.org/support/topic/plugin-hitcounter-double-count/#post-1516408)
 * [@blueboxed](https://wordpress.org/support/users/blueboxed/), sorry for the delay
   in getting back to you, I’ve been away.
 * Just had a look at your site, and had another look at the single.php code and
   it might possibly have something to do with line 42 – `if (have_posts()) : while(
   have_posts()) : the_post(); ?>`. Maybe the `the_post` is getting called again
   even if a valid post has been found – therefore counting for a second time.
 * If you look at line 147 in hitcounter.php you’ll see `add_filter('the_post', '
   hc_detectAgent');`. Experiment by changing `the_post` to `the_excerpt` or `the_content`(
   e.g. `add_filter('the_content', 'hc_detectAgent');`) and see if one of those 
   options changes it for you.
 * Alternatively take out the `else` statement in your single.php and create a 404.
   php file to handle errors.
 * Let me know how it goes.

Viewing 15 replies - 1 through 15 (of 16 total)

1 [2](https://wordpress.org/support/topic/plugin-hitcounter-double-count/page/2/?output_format=md)
[→](https://wordpress.org/support/topic/plugin-hitcounter-double-count/page/2/?output_format=md)

The topic ‘[Plugin: hitcounter] Double Count’ is closed to new replies.

 * 16 replies
 * 5 participants
 * Last reply from: [rafdevis](https://wordpress.org/support/users/rafdevis/)
 * Last activity: [15 years, 3 months ago](https://wordpress.org/support/topic/plugin-hitcounter-double-count/page/2/#post-1516409)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
