PHP Notices, Warnings and Errors on Your WordPress Site
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 error messages we recommend Logtivity which has a hosted errors logs service. It doesn’t matter where your site is hosted, Logtivity will record the errors and point you to the file that’s causing problems.
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:
define('WP_DEBUG', true);
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:
ini_set('display_errors','Off'); ini_set('error_reporting', E_ALL ); define('WP_DEBUG_DISPLAY', false);
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. You can use the sharing feature in Logtivity to show them the error.
thnks
Hello Alex! I’m trying to get on with setting up the PHP log to only log the PHP Errors. Whatever i try, it keeps logging everything.
IS this setup in wp-config.php should work? (php 7.4)
[code]define(‘WP_DEBUG’, true);[/code]
[code]define(‘WP_DEBUG_DISPLAY’, false);[/code]
[code]define(‘WP_DEBUG_LOG’, ‘wp-content/themes/mytheme/mylog.log’ );[/code]
[code]ini_set(‘error_reporting’, E_ERROR );[/code]
any idea what i’m doing wrong? (i even tried to set the error reporting in php.ini, with same (no) results..
Best wishes,
define(‘WP_DEBUG’, true);
define(‘WP_DEBUG_DISPLAY’, true);
define(‘WP_DEBUG_LOG’, ‘wp-content/themes/mytheme/mylog.log’ );
ini_set(‘error_reporting’, E_ALL );
ini_set(‘error_reporting’, E_ALL );
Really helped
Tengo estos mensajes que no logro quitar:
Notice: Undefined index: quiz_passing_score in /home/globalticom/public_html/wp-content/plugins/wplms-h5p-plugin/vibebp/class.init.php on line 55
Warning: Use of undefined constant WPLMS_API_NAMESPACE – assumed ‘WPLMS_API_NAMESPACE’ (this will throw an Error in a future version of PHP) in /home/globalticom/public_html/wp-content/plugins/wplms-mycred-addon/vibebp/includes/class.init.php on line 166