Skip to main content

How to Remove PHP Warning Messages in WordPress

Updated over a month ago

If you're seeing PHP warning messages on your live website, it's essential to know that these alerts are meant for development environments only. While they can help debug on a staging site, they should never be visible to visitors on a production site.

Why Warnings Should Be Hidden

PHP warnings do not necessarily indicate something is broken, but they can reveal sensitive information about your site’s structure or server environment. Showing them publicly may:

  • Disrupt the layout of your page

  • Confuse or alarm your visitors

  • Expose paths, file names, or other technical details

Recommended Settings for a Live Website

To disable PHP warnings on your live site, follow these steps:

  1. Check your wp-config.php file
    Open the file located at the root of your WordPress installation and make sure the following lines are set:

    define( 'WP_DEBUG', false ); 
    define( 'WP_DEBUG_DISPLAY', false );

    If these lines are missing, add them just before the line that says
    /* That's all, stop editing! Happy publishing. */.

  2. Alternatively, configure via your hosting panel
    Many hosting providers allow you to manage PHP error visibility directly from their control panel. Look for options like "PHP Settings", "Error Reporting", or "Display Errors", and disable display errors for the live environment.

  3. Clear your cache
    If you're using any caching plugin or server-side cache, make sure to purge it after applying changes.

When Should Warnings Be Visible?

Warnings should only be visible when you are actively debugging on a staging site. In this environment, it's safe (and often helpful) to turn on error reporting using:

define( 'WP_DEBUG', true ); 
define( 'WP_DEBUG_DISPLAY', true );

However, these settings must be turned off before going live.

Did this answer your question?