You logged in your WordPress to update and make a new post and ops what is this? An error message warning top of your dashboard and of course top of your website. This time it is like Warning! Creating default object from empty value in… 5 way to fix and hide this error.

WordPress 5.5.3 and below. This is the example error: Warning! Creating default object from empty value in /home/xxxxxx/public_html/ on line 29

As generally do, probably a plugin is causing this error, so lets find out which plugin is causing this error. You need to inactivate all your plugins one by one and then activate again all the plugins one by one to find out which one is the problematic one.

Okay let’s say you found out which plugin is it. If you think it is not a necessary plugin, until they fix the issue, you can inactivate that plugin and bam error is gone. So, you can keep continue to use, post and update your website.

But if the plugin is the major one, especially the one related to theme, you can’t just inactivate unless decide to use another theme, right? And your theme owner company is too busy to answer your questions about the fixing issue, host company is not helping either, and telling you that “go talk to your developer”. This may be one of those very frustrating issue.

Here you are a few easy fix to use on your WordPress to hide that error until someone really fix the plugin, you can use easily. Because this error is not causing any functional and working error, or making problem on your website, so just hiding the error message is enough for you for now.

How to Hide Error / Warning: Creating Default Object From Empty Value

1- On your .php folders find, wp-config.pgp (directly under your domain folder): Look at below code, this may not work with this error, but you can use to hide this for some other type of WordPress errors too.

define('WP_DEBUG', false);

2- Add below code to your .PHP file that sending the warning, just before the IF statement, somewhere beginning of the page and update the page.


3- This should stop the error too. Add it to your active themes functions.php (wp-content/themes/your theme/functions.php):

/* Stop errors if any /error_reporting(E_ERROR | E_PARSE);/ End stop Errors */

4- The following 2 lines should be added to to your .PHP file sending the warning just before the IF statement.

$query_context = new stdClass();
$query_context->context = array();

5- If other methods and codes didn’t work, then add those lines to your .PHP file sending the warning just before the IF statement.

/* suppress error with this */
ini_set('display_errors', 0);

$query_context = new stdClass();    
$query_context->context = array();

You can use Adobe DreamWeaver or any other type of program to edit and update your .php files or directly use your cPanel and edit in files section. So edit your file and update, and see if your error message is hide it and gone.

READ:  Why Get a Custom Web Design?