Websites are never too far from problems. If you run a WordPress website, you will need to spot and fix problems.
WordPress works on PHP. When PHP runs into issues, it reports them to you. This may be helpful to you as the website owner, but these same errors may also be seen by your site visitors.
In this tutorial, you will have a brief introduction to these errors. You will learn the different types that might appear on your site front end. You will also master how you can stop them from showing.
If you want an easy way to find all these messages (visible or not), this tutorial shows how to access PHP logs in WordPress. If you want someone else to check for problems, PluginTests is a great way to automatically test WordPress plugins.
There are three main types of PHP messages: notices, warnings, and errors. Let's take a look at each of them.
What are PHP Notices?
PHP notices are the least important. As stated on the official PHP website, you will see PHP notices when:
the script encountered something that could indicate an error, but could also happen in the normal course of running a script
What are PHP Warnings?
Warnings deserve more attention but most likely won't break your website. According to the official PHP website, warnings are:
non-fatal errors. Execution of the script is not halted
What are PHP Errors?
PHP errors are the most important kind of PHP problems. They most likely will break your website. According to the official PHP website, errors are:
Fatal run-time errors. These indicate errors that can not be recovered from, such as a memory allocation problem. Execution of the script is halted.
Solution #1: Disable Error Reporting on Your Site
- In the root of your WordPress website, find the wp-config.php file:
- Make sure you have in the file the following code:
On some hostings, setting WP_DEBUG to true may not work. If this is your case, you may need to add to your wp-config.php the following:
Solution #2: Fix the Problem
This is a crazy idea, right? Fixing an issue is harder than hiding a problem.
Here are some tips to help you fix the problem. Don't forget to backup your site before applying any of them.
- Ensure your WordPress site and all its plugins and themes are up-to-date.
- If you have just updated a plugin and you're seeing errors, try rolling back to a previous version.
- Run a search on Google and WordPress.org. See if someone already reported the same error message. Check if they have found a solution.
- Study the message itself for hints about the issue. Often it will point to the extension or template that has prompted the problems. Disable the plugin or theme to check if that fixes the problem.
- If it does, report the issue to the plugin / theme developer.