[wp-trac] [WordPress Trac] #21436: wp_query with custom post type and category not working

WordPress Trac wp-trac at lists.automattic.com
Tue Aug 7 11:33:39 UTC 2012


#21436: wp_query with custom post type and category not working
-------------------------------+------------------------------
 Reporter:  voilamedia         |       Owner:  voilamedia
     Type:  defect (bug)       |      Status:  new
 Priority:  normal             |   Milestone:  Awaiting Review
Component:  Query              |     Version:  3.4.1
 Severity:  normal             |  Resolution:
 Keywords:  reporter-feedback  |
-------------------------------+------------------------------
Changes (by SergeyBiryukov):

 * keywords:   => reporter-feedback


Comment:

 Couldn't reproduce on a clean install with Twenty Twelve.

 My steps:
 1. Created the post type:
 {{{
 function bluestar_post_type() {
         register_post_type( 'bluestar', array(
                 'label' => 'Bluestars',
                 'public' => true,
                 'taxonomies' => array( 'category', 'post_tag' )
         ) );
 }
 add_action( 'init', 'bluestar_post_type' );
 }}}
 2. Added two posts (Bluestar 1 and Bluestar 2).
 3. Assigned them to different categories (with IDs 66 and 1).
 4. Added your query before the main loop:
 {{{
 $wp_query = new WP_Query();
 $wp_query->query('post_type=bluestar&cat=-1&posts_per_page=-1'); ?>
 }}}
 5. Bluestar 1 was displayed.
 6. Replaced `cat=-1` with `cat=1`.
 7. Bluestar 2 was displayed.

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


More information about the wp-trac mailing list