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 noticed that when I hook into 'wp' it seems to be firing twice -- for example

add_action('wp', 'just_testing');
function just_testing(){
    global $post;
    error_log($post->ID);
}

returns into my error_log the following two entries:

[01-Feb-2013 13:06:58 UTC] 1120
[01-Feb-2013 13:06:58 UTC] 

I searched google and stackexchange and the thread "What would cause the 'wp' action to fire twice per page (but only once per post) in Firefox only?" does not apply because I am getting the two firings in all browsers.

Thanks for any help!

share|improve this question
    
Look at your server access logs, you might actually be requesting twice (e.g. once for the page, second for an AJAX call) –  webaware Feb 1 '13 at 13:25
    
Suppose favicon request? –  Eugene Manuilov Feb 1 '13 at 13:47
    
Your server logs should tell you which files are being requested. That should narrow this down. –  s_ha_dum Feb 1 '13 at 14:26
    
OK Thanks I will check it out. –  user23591 Feb 1 '13 at 14:57

2 Answers 2

It can happen if one of the files you include in the theme is returning 404 Not Found error. Like, if you're linking to a .js or .css or an image which does not exist on that location. Use the Inspector in your browser to see if you get any 404 errors, anywhere.

Fix them and try again.

share|improve this answer

Search for 'wp', and "wp" (quotes included) in the files of your plugins directory and sub-directories (default wp-content/plugins) and your current theme's directory and sub-directories (default wp-content/themes/YOUR-THEME).

In WP core files (3.5), the wp action is only fired once, with do_action_ref_array in wp-includes/class-wp.php. Probably a 3rd party (plugin/theme) is calling do_action('wp'....

Note: a quick way to rule out a misbehaving plugin is put your testing code in your theme's functions.php, rename your plugins directory to something like plugins.temp and access your front-end. Then, rename your plugins directory back to plugins.

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.