Cannot modify header information - headers already sent by...

Warning: Cannot modify header information - headers already sent by (output started at /var/www/wp-content/themes/Lamoon/includes/shortcodes/shortcodes.php:1) in /var/www/wp-includes/pluggable.php on line 1121

I just wanna ask a question, maybe someone of you already had the same problem. I was working and everything was perfect, and suddenly i got this…

Warning: Cannot modify header information - headers already sent by (output started at /var/www/wp-content/themes/Lamoon/includes/shortcodes/shortcodes.php:1) in /var/www/wp-includes/pluggable.php on line 1121

Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Bobby Iliev
Site Moderator
Site Moderator badge
July 14, 2023

Hi there,

Just came across this and wanted to mention, for anyone who comes across this in the future, that this error typically occurs in PHP when you try to modify the HTTP headers after they’ve been sent to the browser. The most common reason for this is when there’s some output, even as little as a single blank line or white space, sent before calling functions like header(), session_start(), or setcookie().

In your case, the error message indicates that output started at /var/www/wp-content/themes/Lamoon/includes/shortcodes/shortcodes.php:1. This suggests that some unexpected output (like a blank line, white space, or HTML) is occurring in the shortcodes.php file, right at the first line.

You can usually fix this issue by ensuring there’s no output, not even white space, before your PHP opening tag <?php. It’s good practice not to close your PHP tag at the end of the file to avoid any accidental white space after the tag.

Here’s what you need to do:

  1. Open the /var/www/wp-content/themes/Lamoon/includes/shortcodes/shortcodes.php file.

  2. Make sure that the very first thing in your file is the opening PHP tag <?php and that there are no spaces or blank lines before it.

  3. Check the end of your PHP file. If it has a closing PHP tag ?>, you may want to remove it. This isn’t necessary and, by removing it, you prevent accidental white space from being added.

  4. Save your changes and re-upload the file to your server, then try reloading your website.

In general, it’s also a good idea to enable error reporting during development. This will make it easier to identify issues. You can do this by adding the following lines to the top of your PHP script:

ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);

Also, sometimes enabling output buffering via your PHP ini file might help. To enable output buffering globally for all your PHP scripts, you can change the output_buffering directive in your php.ini file.



@c-outlet I suggest opening the file /var/www/wp-content/themes/Lamoon/includes/shortcodes/shortcodes.php in a text editor (nano or vim) and checking if the first line is empty.

Any whitespaces/newlines before the <?php tag can cause this error.

Moreover since this is an issue with a premium theme you can ask them directly.

My friend has always the same error after they installed the Hungarian version of WordPress. As I know all problems were solved after reinstalling that, but the original, English version.

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Featured on Community

Get our biweekly newsletter

Sign up for Infrastructure as a Newsletter.

Hollie's Hub for Good

Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.

Become a contributor

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

Welcome to the developer cloud

DigitalOcean makes it simple to launch in the cloud and scale up as you grow — whether you're running one virtual machine or ten thousand.

Learn more
DigitalOcean Cloud Control Panel