{ 8 Intelligent Comments }

WordPress | Warning: Cannot modify header information…

Wordpress Logo


You receive the following or similar error message when viewing pages, editing your content or accessing your WordPress administration area recently.  You may also receive this error while trying to save your template files through the WordPress template editor.


  • You attempted to save a post or page in WordPress and receive the error message below.
  • You attempted to edit one of your theme files and receive this error when saving the file.
  • You see this error message at the top of the browser window when browsing your WordPress blog

Error Message

Warning: Cannot modify header information – headers already sent by (ouput started at /home/xxxxxxx/something.php) in /home/xxxxxxx/something.php on line xxx

Wordpress Error Message


This problem is caused by blank spaces in one or more of your WordPress theme files.  Even if your WordPress was working fine up until recently, any change to WordPress base files such as upgrade, moving servers, moving domains, installing a plugin or any other change could have triggered this issue.  It commonly happens if your PHP files are edited outside the wordpress environment and re-saved back into your themes folders.  Follow the solution below carefully.


Step 1 – Locate & remove the white space from ALL the culprit files

  1. Firstly, let’s examine the error message carefully and interpret it.  In the image below I have highlighted key areas of what’s causing the problem.
  2. error_highlighted

  3. The area highlighted in yellow is the actual filename where the whitespace is located and the are in red is the path on your web server where this PHP file is to be found however you can usually edit these files easily by using WordPress itself.
  4. So now you know the file causing the problem – in my case it’s a PHP file belonging to the All-in-one-seo-pack plugin.  The file causing my problem us aioseop.class.php.  In you case it will most likely be something different and there could probably is multple PHP files with whitespace.
  5. Now I go into WordPress admin and browse to My Plugins
  6. Click Editor.  This opens the PHP editor for the Plugins (not the Themes)
  7. Ok, so we need to check for whitespace in the top or the bottom of this file.  The screenshots below show the top of the aioseop.class.php file.  The area circled in orange is the open php tag and as you can see it has no blank space and is therefore OK.  So we can now check the bottom of the file.
  8. php_top

  9. By scrolling to the bottom of the file I can now see that the closing PHP tag has some whitespace beneath it.  This is indicated by the orange circle in the screenshot below.
  10. php_bottom

  11. Now I simply click my cursor into the bottom line and backspace up to the line with the closing tag on it.
  12. Then click Update File
  13. Test your site.
  14. If you receive another error page mentioning the SAME PHP file then just reload the page and try again.  It could be a cached page.
  15. If you receive another error page mentioning a different PHP file then repeat the steps above until you receive no further error pages.

Please Comment! Add your comments below if this solved your issue or if you found that your setup was different. Please let us know your versions and what exactly you were doing when you had this issue so that we can update this solution and help others with the same problem.


Wow, 8 Comments! We've got a conversation going now. Join the discussion below!

  1. a.hairan says:

    Hi, I have that error message and want to remove the whitespace but can’t have access to the admin panel. Everytime I login to the admin area, the whole page turns into that message and login fails. What to do?

    1. Rosco says:

      You will need to edit the PHP files in an external editor instead.

      Try logging into your site’s FTP server, locate the folder with your troublesome PHP files. This will usually be in your Themes or Plugin’s folder. Then download the PHP file in the error message and open it with a text editor. If you use Windows then Notepad will be fine. If you use Mac then use TextEdit. Remove the whitespace from the PHP, save the file and re-upload it to your site.
      If you’re still having problems post the error message here.


  2. a.hairan says:

    Thank you for the prompt reply. I copied the file to Notepad. Which whitespaces should I remove?

  3. a.hairan says:

    Sorry, it looks like this in Notepad:

    Simpleindy Theme Settings

    <a style="cursor:pointer;" title="” onclick=”toggleVisibility (‘sindy_featured_tip’);”>

    <input type="checkbox" name="sindy_featured" id="sindy_featured" value="true" ” />

    <a style="cursor:pointer;" title="” onclick=”toggleVisibility(‘sindy_featured_count_tip’);”>

    <input size="1" name="sindy_featured_count" value="”/>

    <a style="cursor:pointer;" title="” onclick=”toggleVisibility (‘sindy_med_featured_tip’);”>

    <input type="checkbox" name="sindy_med_featured" id="sindy_med_featured" value="true" ” />


    <a style="cursor:pointer;" title="” onclick=”toggleVisibility (‘sindy_footer_tip’);”>

    <input type="checkbox" name="sindy_footer" id="sindy_footer" value="true" ” />

    <a style="cursor:pointer;" title="” onclick=”toggleVisibility (‘sindy_thumbnail’);”>

    <input type="checkbox" name="sindy_thumbnail" id="sindy_thumbnail" value="true" ” />

    <input type="submit" name="Submit" value=" »” />

    ‘Sidebar Left’,’before_widget’ => ”,’after_widget’ => ”,’before_title’ => ”,’after_title’ => ”));
    register_sidebar(array(‘name’ => ‘Sidebar Right’,’before_widget’ => ”,’after_widget’ => ”,’before_title’ => ”,’after_title’ => ”));
    register_sidebar(array(‘name’ => ‘footerleft’, ‘before_widget’ => ”,’after_widget’ => ”,’before_title’ => ”,’after_title’ => ”));
    register_sidebar(array(‘name’ => ‘footermiddle’, ‘before_widget’ => ”,’after_widget’ => ”,’before_title’ => ”,’after_title’ => ”));
    register_sidebar(array(‘name’ => ‘footerright’, ‘before_widget’ => ”,’after_widget’ => ”,’before_title’ => ”,’after_title’ => ”));

    //Improve the excerpt
    function improved_trim_excerpt($text) {
    global $post;
    if ( ” == $text ) {
    $text = get_the_content(”);
    $text = apply_filters(‘the_content’, $text);
    $text = str_replace(‘]]>’, ‘]]>’, $text);
    $text = preg_replace(‘@]*?>.*[email protected]’, ”, $text);
    $text = strip_tags($text, ‘‘);
    $excerpt_length = 55;
    $words = explode(‘ ‘, $text, $excerpt_length + 1);
    if (count($words)> $excerpt_length) {
    array_push($words, ‘[…]’);
    $text = implode(‘ ‘, $words);
    return $text;

    remove_filter(‘get_the_excerpt’, ‘wp_trim_excerpt’);
    add_filter(‘get_the_excerpt’, ‘improved_trim_excerpt’);

    function get_thumbnail($postId) {

    // Get the post ID
    $ID = $postId;//$post->ID;

    // Get images for this ID
    $arrImages =& get_children(‘post_type=attachment&post_mime_type=image&post_parent=’ . $ID );

    // If images exist for this page
    if($arrImages) {

    // Get array keys representing attached image numbers
    $arrKeys = array_keys($arrImages);
    $post_title = get_the_title($ID);

    // Get the first image attachment
    $iNum = $arrKeys[0];

    // Get the thumbnail url for the attachment
    $sThumbUrl = wp_get_attachment_thumb_url($iNum);

    //$sImageUrl = wp_get_attachment_url($iNum);

    // Build the string
    $sImgString = ‘
    ‘ .
    ” .

    // Print the image
    echo $sImgString;

    function get_medium_img($postId) {

    // Get the post ID
    $ID = $postId;//$post->ID;

    // Get images for this ID
    $arrImages =& get_children(‘post_type=attachment&post_mime_type=image&post_parent=’ . $ID );

    // If images exist for this page
    if($arrImages) {

    // Get array keys representing attached image numbers
    $arrKeys = array_keys($arrImages);
    $post_title = get_the_title($ID);

    // Get the first image attachment
    $iNum = $arrKeys[0];

    // Get the thumbnail url for the attachment
    $image = wp_get_attachment_image_src($iNum, ‘medium’);
    if ( $image ) {
    list($src, $width, $height) = $image;

    // Build the string
    $sImgString = ‘‘ .
    ” .
    // Print the image
    echo $sImgString;

    add_filter(‘comments_template’, ‘legacy_comments’);

    function legacy_comments($file) {

    if(!function_exists(‘wp_list_comments’)) : // WP 2.7-only check
    $file = TEMPLATEPATH . ‘/legacycomments.php’;

    return $file;

    add_filter(‘get_comments_number’, ‘comment_count’, 0);
    function comment_count( $count ) {
    global $id;
    $comments_for_post = get_comments(‘post_id=’ . $id);
    $comments_by_type = &separate_comments($comments_for_post);
    return count($comments_by_type[‘comment’]);

    function list_pings($comment, $args, $depth) {
    $GLOBALS[‘comment’] = $comment; ?>
    <li id="comment-“>

    <li id=”comment-“>

    says on: at

    comment_approved == ‘0’) : ?>
    Your comment is awaiting moderation.

    $depth, ‘max_depth’ => $args[‘max_depth’]))) ?>

    $post = $my_query->posts[0];

    $post_body = $post->post_excerpt;
    $post_body = substr(strip_tags($post->post_content),0,200);

    echo ‘Featured Post guid . ‘#comments” title=”Comment on ‘ . $post->post_title . ‘”>’.$post->comment_count.’ Comments‘.
    guid.'” rel=”bookmark” title=”Read "’.$post->post_title.’ "”>’.
    $post->post_title .’
    ‘. $post_body .’ guid.'”> Read More… ‘;

  4. Rosco says:

    Email me the php file and I’ll take a look. From what you pasted above it looks like you don’t have an opening PHP tag at all but that could have been a copy/paste problem. Email to [email protected]

  5. jc says:

    I found that I ran into this error when I FTP’d the files down to my local machine in Auto or ASCII mode. I switched this to Binary for the plugins directory and it resolved all of these errors.

  6. Ila Pittman says:

    I tried to publish a comment earlier, however it has not shown up. I imagine your spam filter may be broken?

  7. Issuerbfeen says:

    noted you post: to my @miejavfr twitter

Leave a Reply