[wp-trac] [WordPress Trac] #29660: Functions in wp_includes/query.php assume non-null return value from get_queried_object
WordPress Trac
noreply at wordpress.org
Fri Feb 17 22:01:27 UTC 2017
#29660: Functions in wp_includes/query.php assume non-null return value from
get_queried_object
--------------------------+-----------------------------
Reporter: yellyc | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: Future Release
Component: Query | Version: 4.0
Severity: normal | Resolution:
Keywords: 2nd-opinion | Focuses:
--------------------------+-----------------------------
Comment (by sterlo):
Confirming this is a thing.
{{{
Notice: Trying to get property of non-object in /var/www/html/wp-includes
/class-wp-query.php on line 3516
Notice: Trying to get property of non-object in /var/www/html/wp-includes
/class-wp-query.php on line 3518
Notice: Trying to get property of non-object in /var/www/html/wp-includes
/class-wp-query.php on line 3520
}}}
How I'm getting it to generate:
{{{#!php
<?php
add_filter( 'pre_get_posts', function( \WP_Query $query ) {
if ($query->is_tax() || ( $query->is_category() && !
$query->is_category('blog') )) {
$query->set( 'orderby', [ 'title' => 'ASC' ] );
}
return $query;
});
}}}
That's rather simple, shouldn't be running into trouble with something
like this.
1. Is it a taxonomy? Yes.
2. Is it a category? Yes.
3. Is it THIS (blog) Category? *project explodes*.
Would be nice to fix this.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/29660#comment:24>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list