WordPress Debug is an integrated feature that shows error messages to assist developers in finding and resolving problems. Setting PHP global variables like WP_DEBUG and SCRIPT_DEBUG will allow it. As an alternative, crucial debugging information, such as script execution, may be shown via plugins.
1. Enable WP_DEBUG:
Activating WP_DEBUG is the easiest way to enable debugging in WordPress. It can look for PHP code problems in various website elements, such as plugins and themes.
The WP_DEBUG global variable may be used by simply changing its value from FALSE to TRUE in the wp-config.php file. Make sure you can use a file transfer protocol (FTP) program like FileZilla or the file manager provided by your hosting company to access your WordPress root folder before proceeding.
The PHP file must be downloaded, edited on your PC, and then reuploaded to your website if you use an FTP client.
Users will utilize Hostinger File Manager, which allows them to change wp-config.php right in their web browser, to make things easier. The steps are as follows:
- Open hPanel and log in. Go to Dashboard → File Manager → Websites.
- Open the public_html root folder in WordPress.
- Double-clicking the wp-config.php file will open it.
- Look for the next line. This entry can be manually added after the $table_prefix = ‘wp_’; line if you are unable to find it.
define( 'WP_DEBUG', false );
- Make the value TRUE instead of false.
/**
* WordPress database table prefix.
*
* You can have multiple installations in one database if you give each
* a unique prefix. Only numbers, letters, and underscores please!
*/
$table_prefix = 'wp_';
/**
* For developers: WordPress debugging mode.
*
* Change this to true to enable the display of notices during development.
* It is strongly recommended that plugin and theme developers use WP_DEBUG
* in their development environments.
*
* For information on other constants that can be used for debugging,
* visit the documentation.
*
* @link https://wordpress.org/support/article/debugging-in-wordpress/
*/define( 'WP_DEBUG', true );
/* Add any custom values between this line and the "stop editing" line. */
/* That's all, stop editing! Happy publishing. */
/** Absolute path to the WordPress directory. */
if ( ! defined( 'ABSPATH' ) ) {
define( 'ABSPATH', __DIR__ . '/' );
}
- After making the modifications, click the disk symbol in the editor’s upper right corner.
More PHP parameters are available in WordPress to adjust the debug mode. To maintain the user experience, for instance, WP_DEBUG_DISPLAY, when set to FALSE, conceals the error messages on the front end.
It is commonly used by developers in conjunction with WP_DEBUG_LOG, which provides a list of PHP errors in the debug.log file located within the wp-content directory. These variables are added to wp-config.php above the “That’s all, stop editing!” line, just like in WP_DEBUG. The following code should appear in your configuration:
if ( ! defined( 'WP_DEBUG' ) )
{
define( 'WP_DEBUG', true );
define('WP_DEBUG_DISPLAY', false);
define('WP_DEBUG_LOG', true);
}
Keep in mind that after you enable the WP_DEBUG_LOG variable, WordPress will log any messages that appear. You have to manually reproduce past problems if you wish to record them.
2. Enable SCRIPT_DEBUG:
WordPress employs minified CSS core files and JavaScript (JS) by default, which conceal extraneous information like error messages. Although this speeds up page loading, the lack of comprehensive information makes debugging more challenging.
For simpler debugging, you may load the development versions of the core JS and CSS files by turning on the SCRIPT_DEBUG variable. This is especially helpful if you have lately used these languages to make changes to the appearance of your website.
Using Hostinger File Manager, you can enable SCRIPT_DEBUG in much the same way as WP_DEBUG.
- First, navigate to your WordPress root directory, typically named public_html.
- Then, open the wp-config.php file by double-clicking it.
- Look for the relevant line and switch its value from FALSE to TRUE.
- If the line doesn’t exist, insert it just above the “That’s all, stop editing!” comment.
define( 'SCRIPT_DEBUG', true );
- After you’ve finished editing, click the disk symbol in the upper right corner to save your changes.
Your site will now display error warnings for any fundamental CSS or JavaScript errors if the development versions are enabled. To preserve peak performance after fixing the issues, be sure to disable the variable and return to the minified core files.
3. Enable PHP error log
Using PHP’s error_log() function, you may capture scripting-related problems at the server level. This implies that any PHP-based program, including WordPress and its related database, may be debugged with it. You must make changes to the php.ini file in order to enable PHP logging. However, bear in mind that a lot of web hosting companies limit access to this capability because of design and security constraints.
For those using Hostinger’s managed WordPress plans, this feature can be activated through hPanel.
- Go to Websites → Dashboard → sidebar → Advanced → PHP Configuration after logging into hPanel.
- Click on the PHP options tab.
- To enable logging, check the logErrors box. Enable the displayErrors option if you wish to see the error message on the front end. We advise against checking it.
- Hit Save after scrolling down.
Go to the.log directory in the root folder of your server to examine the log file. You may accomplish this by opening the file manager and finding the.log folder straight from the root directory if you’re using Hostinger File Manager.
- Go to the sidebar → Files → File Manager on your hPanel dashboard.
- Press the “Access all hosting files” button.
- The .log folder should open. This directory may be hidden if you are unable to locate it.
- Uncheck the Hide dotfiles box in the sidebar → Settings to make it visible.
- To view all PHP errors on your website, along with their timestamps and kinds, double-click the error_log_domain_tld file.
4. Enable WPDB error reporting:
You may use the show_errors variable in the wpdb class to identify problems with your WordPress database. By using this, SQL errors will be shown on your website, making it simpler to spot issues with SQL syntax or database connections.
To enable WPDB error reporting through Hostinger File Manager, follow these steps:
public $show_errors = true;
- Navigate to the public_html folder of your WordPress website, then go to wp-includes.
- Open the class-wpdb.php file by double-clicking on it. Look for the line defining the class wpdb.
- Inside its brackets, locate the $show_errors variable and set its value to TRUE, like this:
- public $show_errors = true;
- Finally, click the disk icon to save the changes.