How to debug WordPress issues like a PRO

If you've worked with WordPress for a long time, you may recognize it as sort of like your little brother; you’ve had your moments of joy with it, anger, or even disappointment. Your relationship with this CMS may be one of love and hate, although likely more of love, than hate. However, as often happens with any hobby or profession, there comes a moment of immense frustration when encountering a major flaw on our website, especially when we do not know where it originates from, where it is going, and why this situation has now made our warm morning coffee taste bitter.

Pablo Cortés
CMS Specialist

As the song goes - don't worry, be happy. In this blog post, I will teach you a method that many WordPress professionals don’t utilize or are otherwise unaware of. You are about to increase your WordPress knowledge in such a way that will open up to you a world of solutions to the various errors you may be having with your WordPress site that, as of right now, you don’t know how to deal with or where to find the the source of the problem. This method, which is called Debug Mode, will tell you which plugins or what actions of the template you are using cause errors or any type of problem (big or small) in your WordPress installation.

How is a Debug Mode helpful?

Surely you understand that debug means to get rid of the bugs in your WordPress website, but...what exactly is a bug? In any web project, a bug is an action or element that is causing a certain type of problem, and that problem may be causing other problems at various levels. If you have a bug problem in your house, you may use a spray, typically a few inches away from the bugs to get rid of them. I am going to show you a tool you can use against virtual bugs.

In the case of WordPress, Debug Mode helps you debug any type of error, related to the performance of your website, security, and its general operation.

When should I use Debug Mode?

There are many different scenarios for when you would use Debug Mode, but some of the most common ones are:

  • When an error 500 appears on your website.
  • When you come across the famous "WSOD” (White Screen of Death), which does not let you access your front-end, nor your backend.
  • If you are using a template that you don't know much about, or that you don't really trust (ahem, Themeforest), and you think that this theme is what’s causing conflicts with a trusted plugin.
  • In general, if the web has been “broken”, and at first glance you can't figure out which plugin/template is causing which error.

A few key considerations prior to activating Debug Mode in WordPress:

When using this method, you will feel like a superhero. However, with great power comes great responsibility.

Because of this, you must consider some key points before using the Debug Mode in WordPress:

  • Never use it in a production site (make a copy of it and do it in your local machine or in another WordPress instance).
  • Use the Debug Mode in the shortest amount of time possible (as it may be a backdoor for hackers).
  • If you must use this mode in a production site, at least hide the debug messages to the public (I will show you how).

How to activate Debug Mode in WordPress?

In order to activate Debug Mode, simply go to the files of your WordPress installation in your favorite FTP application, and find the archive called wp-config.php in the root of the installation. Copy this code there:

define('WP_DEBUG', true);

If you want to activate a log to track all the errors in a file (recommended) copy this phrase in there as well:

define('WP_DEBUG_LOG', true);

And to hide these messages from the “public access”, copy the following code, which will write the log messages in the hidden file, as opposed to the public pages of your website:

define('WP_DEBUG_DISPLAY', false);

Video Tutorial: Activating Debug Mode in WordPress

In the following video, we are going to activate the Debug Mode in a WordPress installation, and solve an example “issue” that, at first glance, we would not see.

As you can see, this powerful Debug Mode gives you superpowers to solve critical errors and issues in your WordPress installation. Now that you’ve learned this, I hope you feel more confident about your technical knowledge facing WordPress going forward, and that this will bring you further success with your projects.

Thanks for reading, and see you in the next one!