Debugging WordPress

When WordPress misbehaves, it can be hard to track down the cause. Fortunately, a simple setting in the configuration file can be changed to enable diagnostic messages that usually point you to the culprit.

To enable WordPress debugging, use FTP, your web hosting file manager (found in cPanel or Plesk), or SSH, and edit the wp-config.php file. If you scroll toward the bottom of the file, you'll see a line like this:

 * For developers: WordPress debugging mode.
define( 'WP_DEBUG', false );

Change the "false" to "true" (without the quotes) and save the file.

Now, when you go your site in a browser, you'll (hopefully) see PHP notices and errors. The errors might specifically state the issue that will lead you to a solution, but if not, take note of the filename mentioned at the end of the error. Usually the error will either be in a theme or plugin.

If an error is in a theme, it will look similar this:

... in /home/user/public_html/wp-content/themes/YourTheme/anyfile.php

Note the "themes/YourTheme" in the above example. Whatever comes after "themes" is the name of the theme. You'll likely recognize it as the current theme of your site. If you see this error, upgrading your theme to the latest version might resolve the issue. If not, you can temporarily disable the theme via FTP or the file manager by changing the "YourTheme" folder name to another name. Your site will temporarily revert back to a default WordPress theme, giving you access to the WP admin dashboard to make further repairs.

If an error is in a plugin, it will look something like this:

... in /home/user/public_html/wp-content/plugins/cool-plugin/anyfile.php

In this example, the "plugins" in the file path tells you the error is happening within a plugin. The text after "plugins" is the name of the offending plugin. In this example, it's called "cool-plugin". Upgrading (or temporarily disabling) this plugin may fix your site. To disable a plugin via FTP or the file manager, simply back up then delete the "cool-plugin" (change the name to match your problematic plugin) folder.

These steps should get you back in business, if not completely, at least to where you can get back into the WordPress admin dashboard to upgrade your themes and plugins. If you're still experiencing issues, you can try disabling plugins one by one in the dashboard until you find the issue.

In my experience, most WordPress problems revolve around a plugin or theme, and in the overwhelming majority of those cases, updating WordPress, the plugin, and/or the theme in question will fix the issue. If not, it's possible that the plugin or theme doesn't have support for the most current WordPress version. In this case, go to the website of the vendor of the plugin and theme and check for any news or support information they may have to offer.

Once you're done, don't forget to change the WP_DEBUG line in wp-config.php to "false" (without the quotes). If you don't, PHP notices may continue to be visible on your website.