How to enable debug mode in WordPress?

As of right now, WordPress is the most popular content management system on the planet. If you run a WordPress site, you have almost certainly run into a theme or plugin code conflict. Enabling debug mode may assist you in determining why your WordPress site is not functioning properly.

The 'debug' mode added straight into the WordPress code may be used to address even the most basic of issues, so let me provide some instructions before listing the plugins I recommend. In many circumstances, there is no need to install any plugins in order to detect issues.

The tools provided in WordPress, as well as the logs accessible in your server administration panel, might be of use here. If you use one of the most common systems, Plesk or cPanel, I will show you how to find them in this post.

In the final section of this article, I mentioned some plugins that might aid you in troubleshooting. The tools I have included in this post are some of the best out there for debugging and fixing WordPress issues.

How to debug WordPress without any third-party plugin?

Before I list the plugins I suggest, let me explain how to use the built-in WordPress debug mode to identify the most basic problems. Using PHP error logs to debug WordPress plugins and themes is one of the best ways to find out what is wrong.

In order to save server resources, error logs are turned off by default. They may also be a security issue if the logs are presented in the front-end, since they might disclose potential vulnerabilities.

How to enable debugging mode in WordPress?

In general, the process of enabling debug mode may be broken down into three steps.

  1. Use an FTP client or File Manager to go to WordPress's root directory.
  2. Find the wp-config.php file in your WordPress installation.
  3. Set the 'WP_DEBUG' constant to true.

How to find wp-config.php in WordPress's root directory?

Enabling debug mode in WordPress requires access to the directory where your website is installed through FTP or cPanel/Plesk file management. To utilize this functionality, open the wp-config.php file and locate the line of code shown below.

define( 'WP_DEBUG', false );

To use the debugging function, all you have to do is change 'false' with 'true'. If you do not locate it anywhere in wp-config.php, you may add it at the end.

define( 'WP_DEBUG', true );
If you do not want front-end visitors to see any information on your website, you can make WordPress save errors and notices to a different file instead of showing them publicly. More information is available in the official documentation.

Upon enabling debug mode, all PHP errors, notifications, and warnings will be shown. This may result in warnings being shown for code that is not broken, but do not properly match PHP standards, so please keep that in mind while using this tool.

Sample warning displayed in WordPress debug mode

Deprecated functions and hooks used by WordPress or third-party plugins will also be shown in debug mode. These have not yet been deleted from the source code, but will be in the near future. Deprecation notices are typically accompanied with a recommendation for a new function to be used in its place.

Accordingly, even if your website does operate to some level, it is still best not to disregard the warnings that are given for security and bug prevention reasons.

How to enable Debug Mode with Kinsta?
If you use dedicated WordPress hosting, you may be able to enable debug mode even more easily, like with Kinsta.

What is the location of the debug log in Plesk?

If you are having trouble debugging WordPress, the server logs are a great place to start. From my experience, I can tell you that not all problems are logged in WordPress debug mode.

You may also examine the PHP error log in the admin panel if your hosting company uses Plesk. To access it, go to the main panel, choose the domain, and click the "Logs" button.

Plesk debug log

Once the log information has been shown, you may use the dropdown box above to filter the entries to show just the errors.

Filter Plesk debug log

What is the location of the debug log in cPanel?

The instructions for cPanel are fairly similar to those for Plesk. Instead of repeating what can be found on Plesk's website, I will just link to it.

You may also view the debug log through cPanel's "Errors" section.

How to use WooCommerce Status Report?

Not everyone is aware that WooCoomerce may be used to get general information about your server. What is more, the information presented there may be useful even if the problem is not caused by WooCommerce.

Use the "WooCommerce -> Status" link in the admin menu to see it. The information presented there includes, for example, PHP version, database size, and a list of active plugins. The latter may be highly valuable if you need to submit this information to the plugin/theme developer so that they can duplicate your environment and debug the issue you have experienced.

Debug WooCommerce issues

How to access WooCommerce logs?
There is also a "Logs" area where you may see the contents of WooCommerce problem logs.

How to utilize the browser's console to debug JS and CSS?

Front-end code is often overlooked by WordPress developers. As a consequence, the HTML, CSS, and JS code generated by their plugins is inefficient and poorly written. Generally, using JavaScript to compose the complete web page's content and layout is a bad idea since it makes your site's pages harder to access and less responsive. Another prevalent issue is that certain website components are not consistently supported across browsers, which causes them to screw up for some visitors.

If your interactive functionality is not working properly, it might be due to JavaScript errors or plugin incompatibilities. This might be the situation if the slider, buttons, or other widgets are not functioning properly, for example.

Firefox Developer Tools

Fortunately, all popular browsers have developer tools that may be used to track out such issues. Attaching a screenshot of your browser's console log when submitting your support request may help the developers in fixing the problem you are experiencing.

You may make live changes to your website's front-end code using the browser developer tools without impacting other users. Using these, you can quickly identify the HTML and CSS code responsible for a certain content element and interact with it using live preview.

Debugging JS & CSS
Getting to the console log differs depending on the browser you are using. Please see the WordPress documentation for additional information on how to utilize developer tools in Chrome, Firefox, and Safari.

How can you use Query Monitor to debug WordPress plugins and themes?

Now that I have given you some insight into the debug tools included in WordPress and WooCommerce, I would like to highlight the first plugin that saved me a lot of time. The Query Monitor plugin is highly recommended by many WordPress developers and businesses, and for good reason.

Query Monitor

It includes an easy-to-use interface that allows you to quickly identify not just PHP errors, but also issues with queries sent to the database.

Query Monitor features

Query Monitor can be used to debug WordPress problems

You may also use it to determine which plugin is slowing down or creating troubles on your site. Furthermore, you can also access information about your server on the "Environment" page, similar to the Status Report built into WooCommerce.

Query Monitor overview

How to debug WordPress email sending?

If you moved your WordPress website or built a new one in a fresh environment, the contact forms may not be delivering emails. Your server is most likely not correctly setup to use the PHP mail() function, which is the most likely cause of these frustrating WordPres issue.

If your website is hosted on shared hosting, the mail functionality may be deactivated to decrease the amount of spam. The recipient's server may be blocking messages received from the server for no apparent reason. Whether you have ruled out this scenario, you will need to see if the message has left the outgoing server.

In any case, I recommend using the Post SMTP Mailer/Email Log plugin to track out the source of the issue. It allows you to perform numerous tests and scan your SMTP server for firewall blockages and setup errors. In addition to this, the emails sent via your WordPress website may be logged for troubleshooting purposes.

Post SMTP in repo
Currently, more than 300,000 websites use the Post SMTP plugin.

To be clear, this plugin is not only for troubleshooting the issue of your server not delivering emails. This plugin allows you to configure WordPress to send emails from a third-party server (for example, Gmail) through the SMTP protocol.

Query Monitor

Leave a Reply

Your email address will not be published. Required fields are marked *