[wp-trac] [WordPress Trac] #16465: Querying taxonomies can trigger notices

WordPress Trac wp-trac at lists.automattic.com
Sat Feb 5 17:04:56 UTC 2011


#16465: Querying taxonomies can trigger notices
-----------------------------------------+------------------------------
 Reporter:  hakre                        |       Owner:
     Type:  defect (bug)                 |      Status:  new
 Priority:  normal                       |   Milestone:  Awaiting Review
Component:  Warnings/Notices             |     Version:  3.1
 Severity:  normal                       |  Resolution:
 Keywords:  has-patch reporter-feedback  |
-----------------------------------------+------------------------------

Comment (by hakre):

 Replying to [comment:3 scribu]:
 > Please provide some steps to reproduce.

 Add the following code prior init and after add_filter has become
 available (e.g. must-use plugin), it's adding a tax_query to any query.

 Then request homepage or feed.

 {{{
 add_filter('pre_get_posts', function(WP_query $query) {
         $taxonomyQuery = array(
                 'taxonomy' => 'category',
             );
         isset($query->query_vars['tax_query'])
             || $query->query_vars['tax_query'] = array()
             ;
         $query->query_vars['tax_query'][] = $taxonomyQuery;
 });
 }}}

 Default values should normally take care of the other array entries I've
 not used here.

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/16465#comment:4>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list