Hosting

The easiest way to control the WordPress debug tools is by opening the management page for your WordPress installation via the hosting Control Panel > WordPress Manager and navigating to the Debugging section. Once there, select the checkboxes for the debug tools that you wish to use, and press the Save button.

WordPress Manager debugging

Note: When you enable the WP_DEBUG option via the hosting Control Panel > WordPress Manager, the WP_DEBUG_DISPLAY option will be automatically enabled as well, so you can easily view the debug information in the HTML content of your website.

Enabling Debug mode for WordPress using WP-CLI

You can also manage the debugging tools for your WordPress installation using the Command Line Interface for WordPress (WP-CLI). WP-CLI is supported by default for all hosting accounts on our servers. You can find additional information about WP-CLI in our WP-CLI Tutorial.

Controlling the debug tools for a WordPress installation is very easy with WP-CLI. All you need to do is follow these steps:

  1. Enable SSH access for your account, and connect to it via SSH.

  2. Once you connect to your account via SSH, navigate to the directory of your WordPress installation. If WordPress is installed on your main domain, you should navigate to the ~/www/www directory of your account with the following command:

    cd ~/www/www

  3. The debug tools are managed via the wp config set command which allows you to modify the WordPress configuration file. Depending on the debug tool that you wish to enable, you will need to use different options for the WP-CLI command:

    To enable the WP_DEBUG tool, you should execute this WP-CLI command:

    wp config set --raw WP_DEBUG true
    After you enable the WP_DEBUG tool, you need to decide how you wish to have the debug information provided to you. If you wish to view the information in the HTML part of your WordPress pages, use this command:

    wp config set --raw WP_DEBUG_DISPLAY true
    If you wish to have the debug information stored in a log file within your WordPress installation (debug.log in the wp-content directory), run this command:

    wp config set --raw WP_DEBUG_LOG true
    You can also store the debug information to a custom file on your account (e.g. ~/private/debug.log) using the following WP-CLI command:

    wp config set WP_DEBUG_LOG "/home/$USER/private/debug.log"
    To enable the SCRIPT_DEBUG and SAVEQUERIES tools for your WordPress installation, you can run these commands:

    wp config set SCRIPT_DEBUG --raw true
    wp config set SAVEQUERIES --raw true
    If you wish to deactivate a specific debug tool for your WordPress installation, you can use the WP-CLI command for enabling that feature, but the value should be replaced from true to false.

Enabling Debug mode for WordPress by editing the WordPress configuration file (wp-config.php)

The last method for managing the various debug options of WordPress is by manually editing the WordPress configuration file (wp-config.php). You can do this quickly via the hosting Control Panel > File Manager section by following these steps:

  1. Navigate to the directory of your WordPress installation. If your WordPress installation runs on the main domain for your account, you will need to navigate to the ~/www/www directory.

  2. Click on the name of the wp-config.php file or the Edit (Edit) button next to the file to edit it.

  3. The Edit file page for the wp-config.php file will open up. You will need to add a specific line of code for every debug tool that you wish to enable. It is important that you add the new lines before the following line within the wp-config.php or the debug tools will not be enabled correctly:

    /* That's all, stop editing! Happy publishing. */
    Note: If a specific debug feature is already defined in your WordPress configuration file, you should only modify its value (e.g. from false to true) instead of adding a new line for it.

    To enable debug mode for WordPress, you need to add this line of code to your wp-config.php file:

    define( 'WP_DEBUG', true );
    To have the debug details displayed on your WordPress pages within the HTML part, add this line of code to your WordPress configuration file:

    define( 'WP_DEBUG_DISPLAY', true );
    If you want to have the debug details stored in a log file (e.g. debug.log within your WordPress installation's wp-content directory), add this line:

    define( 'WP_DEBUG_LOG', true );
    In case you wish to use a custom log file (e.g. а debug.log file within the Private directory of your account), you should insert this line of code to your wp-config.php file:

    define( 'WP_DEBUG_LOG', '/home/USERNAME/private/debug.log' );
    Note: You will need to replace USERNAME with your hosting account username.

    To enable the SCRIPT_DEBUG tool, you have to add this line to your WordPress configuration file:

    define( 'SCRIPT_DEBUG', true );
    You will need to add this line if you want to enable the SAVEQUERIES WordPress debug tool:

    define( 'SAVEQUERIES', true );
    Should you want to disable a given debug tool that is already enabled for your WordPress installation, you just have to set its value to false without quotes.

Viewing MySQL queries from the SAVEQUERIES debug tool

Once you have enabled the SAVEQUERIES debug tool in WordPress, you will need to use the $wpdb->queries global object to actually see the queries. The simplest way to do this is by adding the following code block to the footer PHP file of your theme (e.g. ~/www/www/wp-content/themes/twentytwentythree/patterns/footer-default.php if you use the Twenty Twenty-Three WordPress theme):

<?php
if ( current_user_can( 'administrator' ) ) {
    global $wpdb;
    echo "<pre>";
    print_r( $wpdb->queries );
    echo "</pre>";
}
?>

The code block will get the SAVEQUERIES debug information printed to all users with administrator access. You can add the code block right before the closing paragraph tag (</p>) using the hosting Control Panel > File Manager section.