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
Warning: Cannot modify header information – headers already sent by (ouput started at /home/xxxxxxx/something.php) in /home/xxxxxxx/something.php on line xxx
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
- 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.
- 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.
- 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.
- Now I go into WordPress admin and browse to My Plugins
- Click Editor. This opens the PHP editor for the Plugins (not the Themes)
- 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.
- 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.
- Now I simply click my cursor into the bottom line and backspace up to the line with the closing tag on it.
- Then click Update File
- Test your site.
- 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.
- 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.