WordPress Debugging: How To Enable WP_DEBUG?

There is nothing in the world termed as Ideal or perfect. Everything that exists whether it is a smartphone or your work efficiency or even humans cannot be perfect. Similarly, there are no CMS available till now which has no issues or Errors present in them. No matter how big their market share is and how popular it is.

We can only reduce or eliminate the bugs from time to time. Similarly in WordPress, to remove errors or bugs you need to enable WordPress Debug to get bugs to report if there is any. In addition to it, there are also third-party tools available that can help you in WordPress debug.

In this post, we will try to get into depth about What WordPress Debug is? How you can enable it on your WordPress and the alternate ways in which you can start WordPress Debug.

What do you mean by WordPress Debug or Debugging?

The word Debug or Debugging simply means to detect or identify the possible errors or bugs (in terms of IT) in your program or codes. In the process of Debugging, after identifying the bugs the final step is to make sure the bug has been removed, the issue has been resolved, and make ensure that it won’t happen in the future again.

This debugging process is mainly carried or performed by coders or developers by using various tools available online, and it is one of the crucial stages of any software development process.

This process is usually done in various sub-stages with proper strategies hence, before publishing any software or code, it has to go through various testing stages where developers or coders try to identify any errors or issues. If found any, developers isolate it and try to fix it as soon as possible.

The process can be excruciating and hectic, hence it might take longer than coding the software itself.

What is the function of WordPress Debug?

As you may have known, the core WordPress software is developed on PHP, so are WordPress plugins and themes. So, if there any error occurs, enabling WordPress Debug mode can let you know what is going wrong with WordPress by simply showing an error message, notices, or Warnings in the form of PHP.

Whenever you enable WordPress to debug mode on your WordPress, you will start seeing error messages on your WordPress Dashboard, whenever there is an issue occurs.

After that, you can either fix the problem on your own or ask your developer to solve the occurred.

How to get all WordPress Debug notifications or error logs?

After enabling WordPress Debug mode, you will start receiving warnings, error messages, or notifications regarding errors on your WordPress, but all these messages will not be saved on your WordPress.

However, you can save all your error messages and create error logs. All you need to do is to enable another option i.e WordPress Debug log. Enabling this feature will save all of the error messages, notifications, or warnings to a file on your server.

Whenever you enable WordPress to debug log mode, by making the WP_DEBUG_LOG constant to true. WordPress will start saving all the error messages to the WP-content/debig.log file. However, you can also customize or change the path of this file to the desired location on your server.

In addition to it, you can also change the appearance of errors messages if you like them whether to display or not. And your WordPress debug mode will be still enabled.

How you can enable WordPress debug mode?

Some Webhosting companies provide you with a dedicated link to enable WordPress to debug mode, however, if you do not have that option, you can use either of the two ways:

  1. Enable WordPress Debug mode using WordPress plugin.
  2. Manually Enable WordPress Debug Mode

1. Enable WordPress Debug Mode using WordPress Debug Plugin

If your Web hosting service provider doesn’t provide you a dedicated link to enable WordPress to debug mode, you are can always use WordPress plugins that help you out to enable debug mode. However, when it comes to WordPress plugins there are thousands of plugins are available and it becomes difficult for users to choose the best one.

Hence, for your convenience we recommend you to use the WP Debugging tool available free to download and use in WordPress Directory.

WP Debugging

Screenshot 14 3 WordPress Debugging: How To Enable WP_DEBUG?

WP Debugging is an Open source software and developed by Andy Fragen. When you successfully install and activate the plugin, at that moment it starts working.

The plugin will set the following debug constants in wp-config.php by default, and the default constants will be automatically removed after removing or uninstalling the plugin.

The default settings are:

You can also configure the above options in the WordPress dashboard as well. Go to your WordPress Dashboard > Tools > WP Debugging.

Enabling WordPress Debug on
WordPress Debug enable

After configuring all the WP Debbuging settings, one thing to keep in mind that to deactivate the plugin, so that it can disable the debug mode.

2. Manually Enable WordPress Debug Mode

If you do not like to use WordPress Debug Plugin for any reason, you have a manual option to do that. To enable WordPress to debug mode manually you need to add some constants to your Wp-config.php file.

And to configure your wp-config.php file, you need to connect to your server using the File Transfer Protocol (FTP) client. Most probably you will find the wp-config.php file in your root folder or your website and when you can locate the file, open it and make some edits.

The wp-config.php file mostly contains all your website’s configuration settings, such as settings by web hosting provider, database information, and other vital information. Now to enable the WP debugging, you need to look out for this line of code:

('WP_DEBUG',false);

Now, when you can find the above code line, the next thing you need to do is copy the below code over the

Note: It is not highly recommended to change the WP_DEBUG_DISPLAY to true or else the errors will start displaying on your live website.

After pasting the above code in your wp-config.php file, you need to save the changes and exit the text editor. Now you have successfully activated the Debugging mode.

However, if you like to enable just the basic WordPress debugging mode, you can simply add the code below:


define( 'WP_DEBUG', true );
// To enable WP_DEBUG mode on

Now once you can debug your website, you can disable the debug mode by either setting the constants to false or by simply removing the snippet from the wp-config.php file.

Why it is necessary to disable WP Debug mode once you are done?

No doubt, the WordPress debug mode is very handy if you are trying to fix errors or any other issues with WordPress, But one thing you should note is that the debug mode should not be on after troubleshooting the errors. It is because it will keep showing error texts or messages from your PHP code to your website visitors.

Since we have already mentioned this point in the above sections quite a few times just to remind you to always disable your WordPress debug mode when you are done troubleshooting.

Some tips to debug problems in WordPress

Apart from just activating WP_DEBUG mode to identify the errors on your WordPress, there are also some useful tips and tricks you can follow that help you out to debug problems in Word Press.

For example, when your wordpress site suddenly crashes or shows a white Screen of death. The most common debug method to this problem is to deactivate your plugins and themes and check their updates. This method will help you out to sort out the exact reason behind this reason but this method can be quite time-consuming. And there are also high chances that you might not be able to notice the real problem.

Hence, it becomes necessary that you must use the right tool to identify the root cause of the error and fix it as soon as possible.

1. Enable WordPress Database (WPDP) Error Reporting

You can also detect and identify any problems regarding the WordPress database by enabling WPDP in your WordPress. The object $wpdb has a variable that lets you see all the database errors and it is called $show_errors. If you set this variable to true, all the SQL errors will start displaying for any query.

Now to enable WPDP error reporting, you need to go to your public_html file and look for the wp-dp.php file inside the folder wp-includes. Open the database file and search wpdb class to change the $show_errors variable to true.

2. Look out your Website’s Complete Error logs

On some occasions, you might face an internal server error page while browsing the website. The best thing you can do to fix this error is by checking out your website’s complete error logs.

Just reviewing your website’s complete error logs can be very helpful for anyone to identify the possible culprit. After identifying the possible culprit, if you do not know how to fix it simply a Google search would help you out to provide you with all the possible solutions available.

3. Always Use a WordPress staging platform while playing with codes

It is always said, prevention is better than cure, hence, if you want to reduce the risks or minimize the errors on your WordPress website. The best thing you can do is to make any tweaks or changes first on a Staging platform.

A staging platform or website is an exact copy of your live website and it is hosted on your website’s subdomain. This clone website will work as a testing and development ground where you can add codes and run tests before making it live.

In addition to it, this staging site won’t be visible to any of your website visitors or even search engines won’t be able to find it. Hence, it provides you with a complete environment to do experiments without any limitations and without affecting your live website.

4. You can also Enable SCRIPT_DEBUG mode

To improve your website performance and increase the loading time, wordpress uses CSS and javascript files. But sometimes these java scripts can have some hidden error codes that can create problems for your website.

So to eliminate such problem with script execution, wordpress provide you with a constant which can be added to your wp-config.php file.

All you need to add the snippet ( ‘SCRIPT_DEBUG’, true );

When the script debugs mode is turned true, WordPress will turn all plugins to use their full version and use the development version of CSS and javascript files rather than the compressed versions.

6. Detect or Identify PHP errors

PHP info is one of the very useful files that can help you to detect PHP errors early. The file includes all the information regarding the present state of PHP such as the version, Operating system version, compilation options, License, and many more.

To enable this error reporting method, you need to configure the php.ini file. It is because you do not have been provided with an option to have root access to enable this error reporting feature.

However, you can always use an alternate solution i.e online PHP code checker tool that helps you to provide complete guidance to identify the errors.

Query Monitor Plugin

1. Query Monitor

WordPress Debug tool : Query Monitor Plugin
WordPress Debug tool: Query Monitor

The Query Monitor plugin is one of the best tools available that provide a complete developer tool panel for WordPress. This plugin will let you enable debugging of database queries, HTTP API calls, PHP errors, stylesheets, and many more.

However, there are plenty of other options are also available but they might show compatibility issues with the latest version of WordPress. This plugin is available free to use and download from the WordPress directory and capable of doing the majority of the work.

Some of the key functions that this plugin is capable of:

  • All Database queries.
  • PHP errors.
  • Template filename.
  • Hooks and actions.
  • Block editor blocks.
  • Enqueued scripts and stylesheets.
  • HTTP API requests
  • User capabilities check and many more.

WPOven Review on Query Monitor

Being a Free and open-source software Query Monitor provides some extraordinary features that other plugins can charge you. Whether it is user experience, installation, or complete setup process, the plugin works flawlessly and can able to enable all the necessary options.

However, it slowed down the website speed a little bit but it was worth using. But, you can disable the plugin after successfully debugging your WordPress. I would highly recommend anyone to use this plugin if they are ok with slightly slow website speed. Apart from this, it works like charm.

2. New Relic

WordPress Debug tool: New Relic
WordPress Debug tool: New Relic

If you are looking for a more robust and efficient solution, then you are required to go for some premium option such as the New Relic tool. This tool of the app will let you monitor user experience, discover bottlenecks, analyze issues that are affecting your website performance.

All these features will provide you a complete data about your website issues to work upon and help to deliver the best possible user experience.

You can also experience this tool by 14 days free trial period and then you can decide whether to buy or not.

Some key features you will get in New Relic:

  • Log management
  • Error Tracking
  • Browser Monitoring
  • Applicaiton Monitoring
  • Mobile Monitoring and many more.

WPOven Review on New Relic

We have been using this plugin for quite some time and found it is one of the best performance monitoring tools ever existed. We are quite impressed by its features and overall support provided by the New Relic team. The best part of using this tool is that it is capable of supporting apps that are written in different languages such as Java, Node, Ruby, or Python. On top of that, it has an Open SaaS platform that lets communities develop plugins using open API to monitor the technology of their choice.

The only downside of this plugin I found is that this plugin can be built lighter as its UI takes some time to load. In addition, this plugin is quite expensive for any beginner as compared to other tools that provide the same features.

Summary

If you are looking to eliminate all the bugs or errors on your WordPress site, the best thing you can do is to enable its built-in feature called WordPress debug mode. It is one of the very useful ways through which you can easily view all your PHP errors and warnings that your wordpress is facing.

If your web hosting service provider has provided you with a dedicated option to enable WordPress to debug more or else you have always used alternate paths such as using a WordPress debug plugin or by adding code snippets directly to your wp-config.php file.

If you like to get more help or get much deeper into it, you can also use other premium or third-party tools that make it much easier for you.

If you have any questions regarding WordPress debug or anything you like to add more, that we were unable to mention in this post. Please do let us know in the comment section below.

Frequently Asked Questions

How do I debug WordPress?

There are plenty of ways to debug your WordPress site are:
1. Enable WordPress Debug mode on.
2. Enable WordPress Database Error Reporting (WPDP)
3. Active your Error logs and check out them.
4. Enable Script_debug
5. Use PHP code checker
6. You can also use some tools such as New Relic or Query Monitor

What does debugging in WordPress mean?

The word Debug or Debugging simply means to detect or identify the possible errors or bugs (in terms of IT) in your program or codes. In the process of Debugging, after identifying the bugs the final step is to make sure the bug has been removed, the issue has been resolved, and make ensure that it won’t happen in the future again.

Where do I find WP debug?

Once you have successfully enabled WordPress_debug as well as WordPress_debug_log or set it to true. The error logs will start saving in your debug.log file in your Content directory(wp-content/debug.log). However, you can also change the file path.

Leave a Reply

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