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

WordPress Trac wp-trac at lists.automattic.com
Wed Aug 1 00:33:03 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        |   Keywords:
--------------------------+-----------------------------
 I have declared a custom post type in my theme called bluestar. There are
 some posts i dont want displayed on every page display those posts so i
 added support for categories in my register_post_type function  using this
 solution http://bit.ly/bVazBo

 [[BR]]

 {{{
 'taxonomies' => array('category', 'post_tag')
 }}}

 Using wp_query i am able to output posts that are from that post_type and
 are not in that category using cat-id which works

 {{{
  <?php
   $wp_query = new WP_Query();
   $wp_query->query('post_type=bluestar&cat=-19&posts_per_page=-1'); ?>
 }}}

 '''The issue occurs when you try to do the reverse and only output posts
 from from the bluestar post_type that ARE in a specific category.'''

 '''I have tried two methods both dont work'''

 Method 1 using astraight query like before:

 {{{
  <?php  $wp_query = new WP_Query();
 $wp_query->query('post_type=bluestar&cat=19&posts_per_page=-1'); ?>
 }}}

 Method Two Array


 {{{
 <?php
 $wp_query = new WP_Query();
 $wp_query->query(array( 'post_type' => 'bluestar', 'cat' => 19,
 'posts_per_page' => -1));
 ?>
 }}}

 I have tried several variations but nothing seems to work so i believe its
 a bug. I have tested this in all modern browsers on a mac running mac osx
 mountain lion. I also have tried deactivating all plugins but it still
 persists. I am using the latest version of wp (3.4.1)

 Please advise

 Thanks
 -Yosef

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


More information about the wp-trac mailing list