[wp-trac] [WordPress Trac] #16320: pre_get_posts and category__in affects category dropdown

WordPress Trac wp-trac at lists.automattic.com
Thu Jan 20 17:03:07 UTC 2011


#16320: pre_get_posts and category__in affects category dropdown
--------------------------+-----------------------------
 Reporter:  mmuro         |      Owner:
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  Query         |    Version:  3.1
 Severity:  normal        |   Keywords:
--------------------------+-----------------------------
 If you add the following code as a plugin or to your functions file, the
 category dropdown on the Posts edit screen will select the category
 instead of defaulting to 'View all categories'.

 {{{
 add_filter( 'pre_get_posts','my_posts_query' );

 function my_posts_query( $query ){

 $query->set( 'category__in', array(1) );

 return $query;
 }
 }}}

 I tried changing the query variable to category NOT in to test and it
 correctly defaults to 'View all categories'.

 The above code works properly in 3.0.4.

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/16320>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list