Skip to main content
4 of 4
discovered it was only in FireFox
Tom Auger
  • 7.1k
  • 9
  • 62
  • 84

What would cause the 'wp' action to fire twice per page (but only once per post) in Firefox only?

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.

Tom Auger
  • 7.1k
  • 9
  • 62
  • 84