WP_DEBUG is a WordPress setting that makes hidden errors visible or saves them to a file, which helps find out why a site shows a blank page. It is the first tool people reach for when a site shows a white screen or behaves oddly, because it turns silent failures into readable messages. Used carelessly on a live site, it can also show too much to visitors.
What is WP_DEBUG?
WP_DEBUG is set in the wp-config.php file. With it on, PHPPHP is a programming language that builds your web pages on the computer that hosts your site, just before they reach the visitor. WordPress runs on it. errors and warnings become visible or get logged.
WordPress normally hides most PHP notices and warnings, since visitors have no use for them. WP_DEBUG is a constant you set to true to change that. It is usually combined with two related constants: WP_DEBUG_LOG, which writes messages to a file, and WP_DEBUG_DISPLAY, which decides whether messages appear on the page.
The setting lives in wp-config.php, the configuration file of your WordPressWordPress is free software for building and editing a website in your browser. It is written in PHP, so it builds each page when someone visits. installation. Changing it takes a line of text, but it needs file access, so make a backupA backup is a separate copy of your website's files and database, so you can bring the site back after a mistake, a hack or a failed update. of the file before you edit it.
What WP_DEBUG means for your PHP site
When you plan a PHP upgrade, debug mode shows you what the newer version would complain about. DeprecatedA deprecation is an early warning that a feature still works today but will be removed in a future PHP version, so code using it must be changed in time. functions, undefined variables and changed behavior show up as notices or warnings, long before they turn into fatal errors. Running a copy of the site with debugging on is one of the best ways to find the pluginA WordPress plugin is an add-on you install in WordPress to give your site extra features, such as contact forms, SEO tools or a webshop. or themeA WordPress theme is a ready-made package that decides how your WordPress site looks and how its pages are laid out. Change the theme and the design changes. that needs attention.
The risk is exposure. Error messages often contain file paths, function names and sometimes database details. Showing those on the live front end hands an outsider information about your setup. A debug log file can contain the same details, and it sits inside a folder that web visitors might be able to open unless the server is configured to block it.
How to use it safely
The safest pattern is to debug on a stagingA staging environment is a private copy of your website where you try updates first, so any mistakes happen there and not on the live site. copy, not on the live site. If you must debug live, set the display constant to false and the log constant to true, reproduce the problem once, read the log, and switch debugging off again. Then delete or move the log file.
On a copy, a simple routine works well:
- Make a backup of wp-config.php.
- Set WP_DEBUG to true, and enable logging while keeping display off.
- Load the pages that fail, or the admin screens you want to test.
- Read the new entries in the log and write down which plugin or theme each one points to.
- Set WP_DEBUG back to false.
The entries end up in the error logAn error log is a file where your website's software writes down what went wrong, with the time and place. It is the first thing to check when a site breaks. you can read afterwards. If WordPress shows a critical error instead of a message, recovery modeWordPress recovery mode is a safe mode that starts after a serious error, so you can still log in and switch off the plugin or theme that broke your site. may already have emailed you a link.
When to act
Switch debugging on when a page misbehaves and the cause is unclear, and before you move to a newer PHP versionA PHP version is a numbered edition of PHP, like 8.3. Each edition is looked after for a limited time, then gets security fixes only, then nothing.. Switch it off again as soon as you have what you need. If you find fatal errors on a live site and are not sure what to change, we can take over and fix your WordPress website, and when we update PHP in WordPress, we test the upgrade properly before it goes live.
Frequently asked questions
Where do I set WP_DEBUG?
In the wp-config.php file in the root of your WordPress installation, above the line that says to stop editing. You can reach the file through SFTP or the file manager of your hostingWeb hosting is the service that keeps your website's files on a computer that is always online, so visitors can open your site at any time..
Is it safe to leave WP_DEBUG on?
On a live site, you should not show errors to visitors, because messages can reveal file paths and other details. If you need to debug there, log errors to a file and switch debugging off again when you are done.
Where does WordPress write the debug log?
When logging is enabled with WP_DEBUG_LOG, WordPress writes to a file called debug.log inside the wp-content folder by default. Protect or delete that file afterwards, since it can contain details about your site.
Why does WP_DEBUG show so many warnings after a PHP update?
Newer PHP versions flag deprecated code that older versions allowed. The warnings point to plugins or themes that need an update, and they are an early signal that something may break on a later PHP version.