blog-image
July 14, 2017

How To Debug Your WordPress Errors From Website

WordPress

If you do not have a detailed error message, you will keep guessing the issue until the website suffers from anything unusual. With the detailed error message, you can easily resolve the issue in your WordPress development website.

Have you any good reason for turned off WP_DEBUG When you’re developing your themes and plugins ?

For getting a detailed error message, You need to enable the WP_DEBUG.

~ WP_DEBUG ~
Introduced in WordPress version 2.3.1, this feature has gained a higher importance in the WordPress field.

If we see from the point of view of WordPress, WP_DEBUG is basically a permanent global variable which is also known as a PHP constant, that can be used to turn on/off debugging mode in WordPress.

– Default: The debug mode is turned off, But turn it on when starting work on a new WordPress theme or plugin.

– In the wp-config.php file we can trigger WP_DEBUG. wp-config.php lives in a WordPress directory

* To turn on WP_DEBUG, just add the following code to your wp-config.php file:
define ( ‘WP_DEBUG’, true);

* To turn the debugging mode off, replace the above code with:
define ( ‘WP_DEBUG’, false);

– When WP_DEBUG Turning on (setting to true) then all PHP warnings, notices, and errors to be displayed.

Note –
Every good developer should turn on debugging before getting started on a new plugin or theme. While developers working on code they plan to release publicly, WordPress codex “highly recommended” to use WP_DEBUG mode.

It’s important to keep in mind that WP_DEBUG should not be used on a live site. While it’s a useful feature during development,

It can be dangerous on a live site because text in the PHP notices can reveal details about your code, paths and other information to visitors to your site.

~ WP_DEBUG_LOG ~
– WP_DEBUG_LOG is a companion to WP_DEBUG that causes all errors to also be saved to a debug.

* To turn WP_DEBUG_LOG on, Paste following code to your wp-config.php file:
define ( ‘WP_DEBUG_LOG’, true);

– Now save a log of all errors to a debug.log file. Seeing that we can save the errors, we don’t need them to appear on your site’s pages.

Note –
For WP_DEBUG_LOG to do anything, WP_DEBUG must be enabled (true).

~ WP_DEBUG_DISPLAY ~
– To hide the error messages from showing on your pages as they’re generated, you just need to turn off the WP_DEBUG_DISPLAY constant. This way, the PHP errors won’t be shown inside the HTML of your site.

* To turn WP_DEBUG_DISPLAY off, just add the following code to your wp-config.php file:
define ( ‘WP_DEBUG_DISPLAY’, false);

~ SCRIPT_DEBUG ~
– SCRIPT_DEBUG is a related constant – it will force WordPress to use the “dev” versions of core CSS and JavaScript files rather than the minified versions that are normally loaded.

– This is useful when you are testing modifications to any built-in .js or .css files. Default is false.

* To turn SCRIPT_DEBUG on, just add the following code to your wp-config.php file:
define( ‘SCRIPT_DEBUG’, true );

*** To turn on debugging and log error messages without notices on your site, you just need this code:

// Turn WP_DEBUG on
define ( ‘WP_DEBUG’, true);

// Save errors to /wp-content/debug.log
define ( ‘WP_DEBUG_LOG’, true);

// Hide errors
define ( ‘WP_DEBUG_DISPLAY’, false);
@ini_set(‘display_errors’, 0);

// If you are modifying these core files then you need this code. This enable dev versions of core JS and CSS files
define( ‘SCRIPT_DEBUG’, true );

Don’t forget it’s not recommended to use WP_DEBUG on a live site, for obvious security reasons.

Read about this article : EVANS WordPress Newly Arrived(4.8) Update

Read More

Popular posts like this

Consultation

Free

Get a definite increase in the sales enquiries on your eCommerce store by contacting our highly approachable sales team today!

No Credit Card Required, No Commitment, No Cash.
Call Today 02 6100 4040
24x7 Support [email protected]