Your Dedicated Partner for All Things WordPress

How to Turn Off PHP Errors in WordPress

Table of Contents

At some point, you might have started seeing the PHP error on your WordPress website. They will tell you in which file and in which line the error occurred, it is good as long as you are editing the website.

However, you surely don’t want your users to see this thing. This will leave a negative impact and will rise security concerts. So, you might be searching on How to Turn Off PHP Errors in WordPress.

Here we are with the exact step by step guide on How to Turn Off PHP Errors in WordPress. This will tell you all the steps that you need to take to solve the issue in no time.

There is only one way you can do it. So, the issue will be solved easily.

Before we get into How to Turn Off PHP Errors in WordPress, let’s see why you see this.

Overview of PHP Error

If you are seeing the PHP errors in your WordPress website, it is because of the debugging turned on.

WordPress and all the other scripts allow you to turn on the debugging options. Debugging refers to the terms where you are solving the bugs and developing the website.

It would be great if you could see the exact error when you are developing the website or solving the bugs. However, once you are done debugging, you should turn it off and make your website just like the regular website.

You surely don’t want the users to see the error. This might start causing various security issues.

Also, that might be just turned down your reputation. So, you should never keep it off.

Generally, if you had an error before and you Googled the solution then you might have ended up here. Some websites will suggest you turn on the debugging options to see the error.

However, they don’t tell you to turn off debugging which is the biggest issue. If you turned it on and didn’t turn off, then you would see the PHP errors like you are seeing now.

Therefore, here we will see how you can turn it off, and then you will see the default error instead of seeing the complete error. This is the easiest way to solve it.

Before we begin, please make sure that you don’t have any debugging plugin installed. If you installed any plugin to make you’re debugging easier or faster, then you should first try to deactivate it and try again.

If everything is clear till now, you can continue to the steps and turn off the debugging.

How to Turn Off PHP Errors in WordPress

We will now see the steps to turn off debugging. This will remove the PHP errors too.

Open your WP Directory

Your first job is to open your file manager. To do this, you need to open your cPanel and find the file manager option in it.

Once you find it, you need to open it.

If you have single domain hosting, you can open public_html where you will get various files. However, if you have multi-domain hosting, you need to find your website’s directory. Open the main directory.

Now, you need to find a file called wp-config.php.

You will have to edit the file. You need to make the changes in the code of this file.

To do that, you will need to open the code editor of the file.

You can right-click on the file and then select the “Code edit” button. It will open the file in the directory.

Alternatively, you can also download the file and open it in any editor. It is highly recommended to download the file even if you are making changes in the file. This will make sure that your data is safe.

Therefore, you should download the file. Now, it is up to you whether you want to edit it online or download it on your computer and edit it there.

We will now see what changes you need to make in the file.

Edit this Code

Inside the wp-config.php file, you will see many lines of code. You don’t need technical knowledge. So, chill.

Just look for the following code in the file. You can use Ctrl+f to find it.

define('WP_DEBUG', true);

As most of you might have guessed, you need to change the “true” to “false”. So, just change the single word in the line.

The new line will be as follows. You can also copy the below-given line and replace it with the above line.

define('WP_DEBUG', false);

After doing this, you won’t see the error. However, in some cases, you might still be seeing the error.

So, your next job will be to look for more similar code. Not the same code but the similar code.

In some cases, the display is on. So, you will still see this error even if you added the false to the above line. For that, you will need to turn off the debugging.

Look for the following code. It will be near to the above sentence only.

ini_set('display_errors','On');

ini_set('error_reporting', E_ALL );

define('WP_DEBUG', false);

define('WP_DEBUG_DISPLAY', true);

Once you find the above code, you need to change the above code to off in the first line. Along with this, you also need to set the last line to false. So, the new code will look something like this,

ini_set('display_errors','Off');

ini_set('error_reporting', E_ALL );

define('WP_DEBUG', false);

define('WP_DEBUG_DISPLAY', false);

You can also paste the above-given code if you want.

Save the Changes

Of course, your last step will be to save the changes and reload the website again. You will see that the website error is gone. Not the actual error but you won’t see the PHP errors now.

Please note that it will still display the error name. It is not possible to remove them. For example, you might still see that it is a 502 error or a 405 error. You can’t remove that.

If the problem is not solved, we got other two small ways to solve it.

Other Ways to Hide Errors

In some cases, the above-given method won’t stop showing the error. So, you will need to go with another method. Using that you can easily stop showing the error.

Here are some other ways to do it.

  • Sometimes, it is the theme that is displaying the error and not WordPress. So, you can head over to the theme options and change it from there. You will see the option to disable the debugging. This might change depending on the theme. The best way will be to switching back to the default theme for a while to see if that’s the issue or not.
  • The same applies to the plugins too. One of the plugins might be displaying the errors. Try deactivating all plugins for a while.
  • The last option is to contact support. You can surely contact the hosting support and they will tell you what you need to do next to hide the errors. This will surely work.

Please note that you only need to do these if the above-given techniques don’t work. Therefore, you can first try to use the above technique where we edited the wp-config.php file. That’s the only best way to solve it. The methods given in this section is only for the people whose error isn’t solved yet.

Showing the Errors Again

Now, if you are debugging then you surely might need to see the errors again, right?

So, you can enable them with ease. Most people already know how to enable it. However, if you have still no idea, you can enable it with one line.

Just open your wp-config file. The path is stated above. You can open the file and hit the code edit button.

Find the line where we edit the debugging options. It will be as follows.

define('WP_DEBUG', false);

Change it to true and that’s it.

If you don’t find this line, you will have to add it yourself. You can add the line as follows.

define('WP_DEBUG', true);

Deleting the line will also stop showing the debugging error. If you want to show it again after you have removed the line, you will have to enter the above-given file and then save the changes.

That’s it. Once you make the changes, your website will start showing the errors again.

We suggest you replace true with false if you want to hide the errors again. Deleting the line is not at all recommended. Lastly, it is surely your choice.

Final Words

To conclude, this was all about how to turn off PHP errors in WordPress. You can easily disable this by changing WP debugging true to false in the wp-config file. Please make sure that you have a working backup of the wp-config file before you make the changes. It is just one line so it won’t give many issues. Still, you can take the backup just in case. One file surely won’t take more space. So, you can back it up.

How to get started?

Learn more

WordPress Maintenance

Save 33% with our Annual pricing plan.

Get Started

Looking for help? Chat with us.

Are you in need of assistance or guidance? Look no further! Our dedicated team is here and ready to help. Chat with us today and let’s work together to find the perfect solution for your needs.

Our support team will get you:

I believe every website owner deserves a reliable professional support always by their side.

Alexey Seryapin
Founder of WPServices

Having Troubles With WordPress?

Claim Your Free WordPress Maintenance

In today’s fast-paced digital landscape, every website deserves the care and expertise of a professional maintenance team, ensuring optimal performance, enhanced security, and seamless user experiences, so you can focus on growing your business with peace of mind.

Alexey Seryapin
Founder of WPServices

Coupon Code Applied!

Take your time and continue browsing our services.

Alexey Seryapin
Founder of WPServices