Have an error on your WordPress website? If you’re not able to fix the error, another way to make it go away is to just hide error messages. Just remember, this doesn’t fix the issue – it just removes the message letting you know there’s an issue.
What is a WordPress code error message?
WordPress is coded in the PHP programming language. That language powers the backend and makes it do the heavy lifting and connects to your database. PHP has a few methods of letting you know that theres a problem with the code. One of the most common ways it does this is to output some text on the page. Usually, they start with the text “Warning:“, “Fatal Error:“, or “Parse Error:“. If you have debugging off in the WordPress config file, which it is by default, you may just get a message saying, “There has been a critical error on your website.”.This means that your website was not able to load due to the error and it needs to be fixed.
When we say “WordPress Errors” what we really mean is a PHP Error. WordPress does have some error messages of its own, but most of the time it’ll be a PHP error.
Here’s some examples of what the errors look like:
How to turn on full WordPress error messages:
If you’re only seeing “There has been a critical error on your website.” and you’re confused as to what the actual error is, you’ll need to turn on WordPress debugging.
You’ll have to venture into the code of your website to do this, so if you don’t have access to your hosting or to FTP information, you might be out of luck.
- Find the file wp-config.php in the main directory
- Open the file and find this line: define( ‘WP_DEBUG’, false );
- Change the “false” to “true”
When you reload the the page, you’ll have the actual error message showing (like the second picture above)
2 methods to hide WordPress error messages:
1) The first and best way to remove the message is to fix the error! I know that’s easier said then done sometimes, especially if you’re not a coder.
If you need help, totally reach out to us and maybe we can fix it for you.
2) While it’s not ideal, there are a few ways you can hide error messages. While it does not fix anything, it just removes the message, this can sometimes be the best option if you’re in a rush or not able to fix it.
Turn Debugging Off
WordPress has it’s own set up debuggin options and they’re all controlled by one line of code in the configuration file. If you’re is set to true, just set it to false.
In the wp-config.php file, find this line:
define( 'WP_DEBUG', true);
and change it to:
define( 'WP_DEBUG', false );
If you’re is already set to false, then we’ll have to pull out the big guns and just hide everything using PHP.
Hide WordPress Errors Using PHP
Make your way to the functions file of your theme – wp-content/themes/YOUR THEME/functions.php.
Add this code to the very top of the file after the first “<?php”:
error_reporting(0); ini_set('display_errors', 0);
Again, the best way to remove error messages in WordPress is to fix the actual issue. If you need help, we’re just an email away!