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 getting an error on my site regarding "headers already sent":

Warning: Cannot modify header information - headers already sent by (output started at ........./wp-admin/menu-header.php:161) in ....../wp-includes/pluggable.php on line 881

I read the Wordpress FAQ that discusses this, but - as you can see - this error is caused by the Wordpress core (and not even at the end of a file).

Interestingly, I don't get this error on my local machine. Only on my server.

What can I do about this?

I'm running Wordpress 3.4.2

share|improve this question
2  
Something is messing up your admin menu. Maybe a plugin has registered an options page with broken parameters? Disable all plugins and switch to TwentyEleven. Does it still happen? –  toscho Oct 17 '12 at 23:59
    
@toscho - Actually, now that you're saying, I realize that I probably messed it up. I register my page under the admin_menu action hook, and then do a wp_redirect from within that page (wp_redirect is defined in pluggable.php). Is there a different (earlier) hook I should be using instead? –  Myself Oct 18 '12 at 2:26
    
the hook is correct. Did you exit after wp_redirect? Quoted from the codex "wp_redirect() does not exit automatically and should almost always be followed by exit. " –  Mridul Aggarwal Oct 18 '12 at 7:43
    
@MridulAggarwal - I sure did exit. Since the error originates in pluggable.php, it's clearly caused by the wp_redirect. It's a pity though that I don't get a stack trace. –  Myself Oct 18 '12 at 13:07
    
it sometimes happens that the filename that appears on the screen is not where the error originated. Check if you have some output before you call wp_redirect. Even a space before <?php is enough to create an error –  Mridul Aggarwal Oct 18 '12 at 13:37
show 1 more comment

1 Answer

up vote 3 down vote accepted

Wordpress provides a way to prevent the header HTML from being rendered, by appending &noheader=true to the url.

That will cause the header HTML to wait for you to call it manually, so that you can do a redirect before that.

To later render the header HTML from your page, you'll have to use this:

if ( isset($_GET['noheader']) ) {
    require_once(ABSPATH . 'wp-admin/admin-header.php');
}

For more information, read this article: WordPress and wp_redirect() function problem.

share|improve this answer
add comment

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.