• Skip to main content
  • Skip to primary sidebar
  • Home
  • Windows-Zone
  • Mac-Zone
  • Solutions
  • Tutorials
  • Downloads

Proposed Solution

Technical support solutions, articles and tutorials for Windows, Mac & iPhone

Home > Solutions > Wordpress > WordPress | Warning: Cannot modify header information…

August 13, 2009 by Rosco 8 Comments

WordPress | Warning: Cannot modify header information…

Wordpress Logo

Description

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.

Symptoms

  • 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

Explanation

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.

Solution

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. Sync your files across computers with Dropbox
  7. Click Editor.  This opens the PHP editor for the Plugins (not the Themes)
  8. 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.
  9. php_top

  10. 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.
  11. php_bottom

  12. Now I simply click my cursor into the bottom line and backspace up to the line with the closing tag on it.
  13. Then click Update File
  14. Test your site.
  15. 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.
  16. 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.

Share this:

  • Click to share on Facebook (Opens in new window)
  • Click to share on Twitter (Opens in new window)
  • More
  • Click to share on Reddit (Opens in new window)
  • Click to share on Tumblr (Opens in new window)

Filed Under: Solutions, Wordpress Tagged With: Error, PHP, Solutions, Windows, Wordpress, WP

Reader Interactions

Comments

  1. a.hairan says

    August 28, 2009 at 10:01

    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?

    Reply
    • Rosco says

      August 28, 2009 at 10:31

      Hi,
      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.

      Rosco

      Reply
  2. a.hairan says

    August 28, 2009 at 10:38

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

    Reply
  3. a.hairan says

    August 28, 2009 at 10:40

    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" ” />

    Media’);
    ?>

    <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(‘@]*?>.*?@si’, ”, $text);
    $text = strip_tags($text, ‘‘);
    $excerpt_length = 55;
    $words = explode(‘ ‘, $text, $excerpt_length + 1);
    if (count($words)> $excerpt_length) {
    array_pop($words);
    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);

    // UNCOMMENT THIS IF YOU WANT THE FULL SIZE IMAGE INSTEAD OF THE THUMBNAIL
    //$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’;
    endif;

    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’]))) ?>

    have_posts())
    $post = $my_query->posts[0];

    if($post){
    if($post->post_excerpt){
    $post_body = $post->post_excerpt;
    }else{
    $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… ‘;
    }
    }
    ?>

    Reply
  4. Rosco says

    August 28, 2009 at 10:54

    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 comments@proposedsolution.com

    Reply
  5. jc says

    September 17, 2009 at 01:14

    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.

    Reply
  6. Ila Pittman says

    April 26, 2011 at 11:56

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

    Reply
  7. Issuerbfeen says

    October 28, 2011 at 02:11

    Hi!
    noted you post: to my @miejavfr twitter

    Reply

Leave a Reply Cancel reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Primary Sidebar

Latest Solutions

  • HOWTO: Take A Screenshot – Mac, Windows, iPhone, iPad, Pixel
  • SSD Is The New RAM
  • HOWTO: Move Google Mail (Gmail) Notes to iCloud
  • HOWTO: Sync iCloud Notes Properly On All Your Devices
  • ‘Online Sync & Store’ Vs ‘Backup & Restore’ – What’s The Difference?
  • Windows XP Automatically Logs Off After Login
  • Xcode Installation Alert – Close iTunes During Installation
  • Download & Installing Xcode 4.1
  • SATA Windows XP Driver Finding Service
  • Stop Windows Rebooting Automatically After Updates
  • Windows 7 Boot Error: ‘some file’ is compressed. Press CTRL+ALT+DEL to restart
  • Access Any Country Restricted Website
  • How To Remove MacDefender
  • Online File Sync Speed Test: Mozy, Dropbox, SpiderOak, Mesh, SugarSync
  • 100% Advertising Revenue To Be Donated To Japan

Amazon Deals

Latest Tutorials

  • HOWTO: Take A Screenshot – Mac, Windows, iPhone, iPad, Pixel
  • SSD Is The New RAM
  • HOWTO: Move Google Mail (Gmail) Notes to iCloud
  • HOWTO: Sync iCloud Notes Properly On All Your Devices
  • Internet Privacy – It’s Your Right To Be Anonymous!
  • Create Bootable USB Thumb Drive From ISO Image File (Windows)
  • HOWTO: Setup Gmail & Multiple Google Calendars on iPhone or iPad
  • How To Synchronize Your Files With Another Computer
  • 100% Advertising Revenue To Be Donated To Japan
  • How To Create Your Own VPN
  • Watch TV Online From Other Countries
  • 3 Ways To Save Your Files When Windows Won’t Load
  • Anyone Can…Backup! – Launch Week 50% Discount
  • Windows 7 Icons All The Same
  • Why Is Public Wifi So Slow??

Amazon Deals

Handcrafted with on the Genesis Framework

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish.Accept Read More
Privacy & Cookies Policy

Privacy Overview

This website uses cookies to improve your experience while you navigate through the website. Out of these, the cookies that are categorized as necessary are stored on your browser as they are essential for the working of basic functionalities of the website. We also use third-party cookies that help us analyze and understand how you use this website. These cookies will be stored in your browser only with your consent. You also have the option to opt-out of these cookies. But opting out of some of these cookies may affect your browsing experience.
Necessary
Always Enabled

Necessary cookies are absolutely essential for the website to function properly. This category only includes cookies that ensures basic functionalities and security features of the website. These cookies do not store any personal information.

Non-necessary

Any cookies that may not be particularly necessary for the website to function and is used specifically to collect user personal data via analytics, ads, other embedded contents are termed as non-necessary cookies. It is mandatory to procure user consent prior to running these cookies on your website.