Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I am now experiencing a wired problem with my wordpress installation. I was surprised when I saw post view counter of another post also increased including the the post on which I clicked to try and check the result. I also observed that it increments the post view of another post from the same user.

For more information: I am calling a function from single.php while passing post id to it to display post counter at the bottom of post. In order to trace the issue I used netbeans IDE and found that single.php runs more than once and it passes different post id at first run and subsequently it passes correct post id at the end.

In order to get post id on single.php I used:

<?php $newpostid = get_the_ID(); ?> Total Views <?php echo_views($newpostid); ? echo_views() is a function which directly used to output the updated number using echo statement within it.

Hope someone can help me out of this issue. Thanks.

share|improve this question
    
It's be the loop in single.php that runs more then once. But… it's a loop - you can expect it to run multiple times. Why don't you call your page-view-update function outside the loop instead, and use a different function for displaying it? –  bungeshea Feb 10 '13 at 9:47
    
Where does echo_views() comes from? Please clarify your post and retag it to match the topic. –  Max Yudin Feb 10 '13 at 12:15
    
Would this be related to FireFox's Prefetching? –  s_ha_dum Feb 10 '13 at 17:09
    
Yes s_ha_dum, the issue is with FireFox's Prefetching technology and many many thanks to lead me to the right direction. –  user27256 Feb 11 '13 at 6:25

1 Answer 1

up vote 0 down vote accepted

I am answering this because nobody yet answered this and I think this could help others who are experiencing this kind of issue.

As mentioned by s_ha_dum that the issue is related to FireFox's Prefetching mechanism. In order to resolve this I inserted the below line to function.php:

remove_action('wp_head', 'adjacent_posts_rel_link_wp_head');

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.