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'm using add_action( 'wp', 'do_something_once_per_page' ); and, well, it's not doing it just once but twice. What's interesting is that within do_something_once_per_page( $wp ){ } I'm globalizing $post and it's two different posts!

The way I'm noticing this is with add_user_meta(). Essentially I'm using this to track users' activity within the site. On the 'wp' action, I get the global $page and log the ID against the user's meta.

For every single page load, I'm getting two log entries. One for the correct page, another one for the very next published page (skipping all revisions or other post-types in-between).

Interestingly (is there a clue here?) for posts, only the correct post is recorded - and the action is not invoked a second time.

I'm still surprised that the 'wp' action is being invoked twice at all, even more stumped by the fact that it's grabbing some other page, that has no relationship (in the menu hierarchy) to the current page being queried.

Further, I cannot for the life of me figure out where this "ghost page" is going - it's certainly not being sent to the browser as far as I can tell. Is there some phantom AJAX call that may be responsible? What about the Admin bar when you're logged in (I only record logged in user activity, so there's always an Admin bar).

EDIT: I can now confirm that this is a Firefox-only issue! What's up with that? I can't even begin to fathom how FF is requesting some other page than the link I click on, why only FireFox, and, like, WTF. Probably much less a WP issue than an FF6 issue.

share|improve this question
    
I suggest firing up a client-side debugging tool. Firebug will allow you to track just about all of the HTTP requests that Firefox is making. Fiddler will help you track everything that's going over the wire. That will be a good place to start. –  EAMann Sep 2 '11 at 22:53
    
Thanks for the suggestion. Some threads seem to suggest Firebug is at the cause of it. Others that it has to do with charset encoding causing FF to do a double load (though that wouldn't explain why the request is for a different page) –  Tom Auger Sep 2 '11 at 22:54
    
In that case, disable Firebug and see if the problem persists ... –  EAMann Sep 2 '11 at 22:57

2 Answers 2

up vote 2 down vote accepted

Check the source for your page. I'm guessing that your source code includes a <link rel="next"> in the header, as WordPress injects by default, and Firefox is prefetching the "next" page in order to cache it.

Try this to remove that link from your header:

remove_action('wp_head', 'adjacent_posts_rel_link_wp_head');

Found this blog with more details: Wordpress rel=”next” and Firefox Prefetching

share|improve this answer
    
you are GOLDEN! that was it exactly. You're google-fu is most impressive. I was unable to unearth that one. Thanks! –  Tom Auger Sep 6 '11 at 13:10

Check that you it is not prefetching links. Basically, Wordpress themes might print a directive that direct modern browsers to download and cache the next page you are likely to see to improve performance. The html ouput looks something like this

<link rel="prefetch" href="http://www.example.com/">

Search for link prefetching on Google to learn more.

share|improve this answer
    
Yep. Check the accepted answer. –  Tom Auger Jul 7 '12 at 4:20

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.