user3011401
user3011401

Reputation: 31

Hide Fatal Error in Wordpress

I need help with hiding Fatal Errors from my wordpress site display.

I tried using the following in wp-config.php but it didn't work:

error_reporting(0); 
@ini_set('display_errors', 0);

I still see this fatal error being displayed.

I also have this in my wp-config.php

define('WP_DEBUG', false);

Currently I have an error_log in the wordpress root. I do want to know what the errors are, just don't want them to be displayed to end users, because that would expose my cp username.

Upvotes: 0

Views: 6240

Answers (3)

user3011401
user3011401

Reputation: 31

I found an easier way, but thanks so much for all of your suggestions, I got to learn new stuff while trying out the suggestions.

In the end I went to my Cpanel-> php.ini QuickConfig -> under display errors, I simply selected the radio button 'off'

And everything worked.

Thanks!

Upvotes: 1

user862412
user862412

Reputation:

Try inserting this in your index.php

error_reporting(0);
ini_set('display_errors', 0);

or this in .htaccess

# supress php errors
php_flag display_startup_errors off
php_flag display_errors off
php_flag html_errors off
php_value docref_root 0
php_value docref_ext 0

or just fix them :)

Upvotes: 4

Yves Lange
Yves Lange

Reputation: 3974

It is not a good thing to hide errors. You should fix it. This error is not related to Wordpress, it's a PHP error.

You have two options:

  • disable the error reporting in php settings (file php.ini on the server) and put: "display_errors" to "off"

  • or add a .htaccess file to your wordpress directory (or modify it if it already exists). You should add those lines in it:

    php_flag display_errors off

    php_flag html_errors off

Please for the second solution you should check if the .htaccess is in override mode (so you need an access to the server configuration files.

Upvotes: 1

Related Questions