More fixes

"Warning:" or "Deprecated:" lines across the top of your WordPress site

Your pages open with a block of technical text such as Warning: Cannot modify header information - headers already sent or Deprecated: Creation of dynamic property, often with a file path from your server. Visitors read it as a broken or hacked site, it can push your layout down, and some of these messages also stop logins and forms from working. Below is a rebuilt example (not a real client), the two-minute check, and the fix for each cause.

What a visitor sees

What the check found


  

The two-minute check

  1. Read the first word and the file path. Deprecated and Notice are harmless old-code messages that should never be shown to visitors. Warning means something did not run as intended. The path after in /.../wp-content/plugins/name/ or /themes/name/ tells you which plugin or theme sent it.
  2. Open wp-config.php (hosting File Manager or SFTP, in the folder that holds wp-admin) and look for WP_DEBUG. If it says true on your live site, that alone explains most cases (row 1).
  3. Check what changed. Did your host move you to a newer PHP version, or did you update a plugin or theme the day the messages appeared? Your hosting panel shows the PHP version (row 2).
  4. Try to log in and send your contact form. If the message says headers already sent, logins, redirects and form confirmations often fail too (row 3).

What causes it and the fix

What you seeWhy it happensThe fix
Many Deprecated, Notice or Warning lines on every pageDebug mode was left on in wp-config.php (often after someone troubleshot the site), so WordPress prints every message to visitorsKeep the messages, but send them to a private log instead of the page. In wp-config.php, above the line that says "That's all, stop editing":
define( 'WP_DEBUG', true );
define( 'WP_DEBUG_LOG', true );
define( 'WP_DEBUG_DISPLAY', false );
@ini_set( 'display_errors', 0 );
Or set WP_DEBUG to false once nothing needs investigating. Change the existing lines; do not add a second copy
Deprecated: ... or Warning: Undefined array key appeared after your host upgraded PHPAn older plugin or theme was written for an earlier PHP version. Newer PHP reports code it is retiringUpdate the plugin or theme named in the path. If it has had no update in a year or more, replace it with a maintained one. Do not move back to an old PHP version for long: it stops getting security fixes (see outdated PHP)
Warning: Cannot modify header information - headers already sent by (output started at /.../file.php:NN)Something printed text before WordPress sent the page headers. Usually a blank line or space before <?php or after a closing ?> in the file named after "output started at", often functions.php or wp-config.php edited by hand. It also stops logins and redirectsOpen the file and line it names. Delete any blank line or space before the first <?php, and remove a closing ?> at the very end of the file (it is not needed). Save it as UTF-8 without BOM; some editors add an invisible mark that counts as output. If the file is a plugin's, update or replace the plugin
Warnings show even though WP_DEBUG is falseThe hosting account has PHP's display_errors switched on, so real warnings still reach the pageIn your hosting panel's PHP settings (cPanel "MultiPHP INI Editor" or "Select PHP Version > Options"), turn display_errors off. Then fix the warning itself: it is still a problem, now just a quiet one
Warning: include(...): Failed to open stream: No such file or directoryA plugin or theme update did not finish and left files missing, or a file was deletedReinstall that plugin or theme from Plugins > Add New or the theme's source (your settings are kept in the database). If the update failed halfway, see update failed
The messages appeared and the editor or a form now says "not a valid JSON response"The warning text is printed inside data the page expected to be clean, so the browser cannot read itFix the warning with the rows above; then see "not a valid JSON response" if the editor still fails

What not to do

Turning debug display off takes a minute. Finding which plugin's code breaks on the new PHP version, replacing an abandoned plugin without losing its settings, or chasing a "headers already sent" that also broke logins is where most owners would rather have someone do it. If that is you, the box below is for that. Related: white screen, login keeps sending you back and outdated PHP version.