Deprecated: Required parameter $location follows optional parameter $post_types in /home1/mybravet/public_html/wp-content/plugins/monarch/monarch.php on line 3783

Warning: session_start(): Session cannot be started after headers have already been sent in /home1/mybravet/public_html/wp-content/themes/Divi Child Theme/header.php on line 1
How to Solve Error: Warning: Creating default object from empty value | WordPress Developer Philippines How to Solve Error: Warning: Creating default object from empty value | WordPress Developer Philippines
Select Page
JF Agno | How to Solve Error: Warning: Creating default object from empty value
  • Facebook
  • Twitter
  • Google+
  • Pinterest

Image Source: E-Deate.com

Usually this error shows at the top of your site something like this

Warning: Creating default object from empty value in ThemeName/functions/admin-hooks.php on line 316

I found 2 ways to solve this but only tested 1 of the solution and it solves the problem so I haven’t check if the 2nd solution will work.

Okay below are a sample code snippets taken from the admin-hooks.php

if ( isset( $query_context->context ) && is_array( $query_context->context ) ) {
return $query_context->context;
} // End IF Statement
$query_context->context = array();

So what I did was to make the variable $query_context to stdClass by declaring this

$query_context = new stdClass();

You will need to add this before you declare the variable to array, so my final code will look something like this

$query_context = new stdClass(); 
 
 if ( isset( $query_context->context ) && is_array( $query_context->context ) ) {
return $query_context->context;
} // End IF Statement
$query_context->context = array();

And that solve my problem if you have questions or suggestions please leave a comment below and here is the original post.

Pin It on Pinterest

Share This