When developing a WordPress site, you may want to turn on the PHP error warnings and notices to ensure that everything is running smoothly before launch.
PHP
Open your site’s wp-config.php document, located in the root of your WordPress install. Look for one of the following lines (either one may appear, but not both).
define('WP_DEBUG', false); // error reporting is off
define('WP_DEBUG', true); // error reporting is on, but may not be displaying
Turning PHP Errors On
Replace the existing line of code (whichever of the above is currently in the document) with the following two lines of code. This will ensure that error reporting is not only on, but also being displayed at the top of the frontend (what your users will see) of your page.
define('WP_DEBUG', true);
define('WP_DEBUG_DISPLAY', true);
Reload the page to see any errors being reported. Make the necessary fixes to your site so that the errors go away.
Turning PHP Errors Off
Once you have the PHP errors fixed, you will want to turn off error reporting.
Comment out the two lines of code you placed to turn on error reporting (or the original one line that was in place if you didn’t replace it above), and place the following four lines of code.
This turns off the PHP error reporting.
// define('WP_DEBUG', true);
// define('WP_DEBUG_DISPLAY', true);
ini_set('display_errors','Off');
ini_set('error_reporting', E_ALL );
define('WP_DEBUG', false);
define('WP_DEBUG_DISPLAY', false);
You can now visit your website to confirm that the PHP errors, notices, and warnings have disappeared from your website.
We’d like to acknowledge that we learned a great deal of our coding from W3Schools and TutorialsPoint, borrowing heavily from their teaching process and excellent code examples. We highly recommend both sites to deepen your experience, and further your coding journey. We’re just hitting the basics here at 1SMARTchicken.
Why 1SMARTchicken?
See More →
Thanks for your support!
WordPress Books
All are affiliate links. Thank you for your support!
WORDPRESS NOTES:
- All modifications to a theme or plugin should be made by creating a child theme and placing the changes there; changes made to the parent theme will be overwritten the next time it updates
Feedback
If you see an error on the page or the code itself is incorrect or incomplete, or just plain wrong, please let us know. We’re always learning. NOTE: we do not sell your information and will not send you spam emails.