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.

One of the key features of WordPress is the ability to enable debug mode, which allows users to see detailed error messages and other debugging information on the frontend of their site. This can be very useful for troubleshooting any problems or issues that may arise with a WordPress site.

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. Additionally, server error logs can also be very helpful for troubleshooting issues with a WordPress site. Most web servers keep detailed logs of all errors and other events that occur on the server, and these logs may be used to identify and resolve PHP errors and warnings.

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.

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.

This data can be accessed from the WordPress admin dashboard by going to "WooCommerce > Status" tab. Once on the WooCommerce Status Report page, users can view detailed information about the current status of their WooCommerce installation, including the version of WooCommerce, the current theme and plugins in use, and the server and WordPress environment. 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.

In addition to the overall status information, the WooCommerce Status Report also provides detailed information about specific components of the WooCommerce site, such as the payment gateways, shipping methods, and tax settings. This can be useful for identifying and troubleshooting any potential issues or problems with these components.

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.

When working with WordPress, it is important to have tools that can help you troubleshoot any problems that may arise. There are many different debugging tools available for WordPress, but some of the most popular and effective ones include the following:

  • Query Monitor
    This plugin provides detailed debugging information for WordPress developers, including information about database queries, PHP errors, and hooks and actions.
  • Post SMTP Mailer/Email Log
    The plugin provides users with a way to send email from their WordPress site using a third-party SMTP (Simple Mail Transfer Protocol) provider, such as Gmail or Mailgun. The plugin also logs all email activity on the site, allowing users to see a record of all email messages that are sent from their WordPress site.
  • User Switching
    The plugin that allows administrators and users with the appropriate permissions to quickly and easily switch between different user accounts on a WordPress site.

Overall, these tools can be very useful for anyone who is working with WordPress and needs to troubleshoot problems or debug their code. It is always a good idea to have a few different debugging tools in your toolkit, so that you can quickly and easily identify and fix any issues that may arise.

Query Monitor

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

Post SMTP Mailer/Email Log

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

User Switching

One of the key features of the User Switching plugin is that it adds a new "Switch To" link to the user list on the WordPress admin dashboard. When clicked, this link allows administrators and other users with the appropriate permissions to switch to a different user account without having to log out and log back in. This makes it much easier and faster to switch between different user accounts, and can be a valuable time-saver for anyone who needs to manage multiple accounts on a WordPress site.

Switch to

Switch back

The plugin also provides a number of other useful features, such as the ability to automatically switch back to the original user account when a user logs out, and the ability to switch to other user accounts from the WordPress login screen.

Overall, the User Switching plugin is a useful tool for anyone who needs to manage multiple user accounts on a WordPress site. It provides a convenient way to switch between different user accounts without having to log out and log back in, and can be a valuable time-saver for administrators and other users who need to manage multiple accounts on a WordPress site.

Leave a Reply

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