[wp-trac] [WordPress Trac] #33827: WP Query: Custom Post Types and Categories

WordPress Trac noreply at wordpress.org
Fri Sep 11 13:02:31 UTC 2015


#33827: WP Query: Custom Post Types and Categories
--------------------------+------------------------------
 Reporter:  atomicjack    |       Owner:
     Type:  defect (bug)  |      Status:  new
 Priority:  normal        |   Milestone:  Awaiting Review
Component:  Query         |     Version:  4.3
 Severity:  normal        |  Resolution:
 Keywords:                |     Focuses:
--------------------------+------------------------------

Comment (by atomicjack):

 Seems that, since custom post types were added, this area of WordPress has
 been left a little untouched.

 Allow me to explain, after a bit of research (and discussing with some
 guys at work), the issue lies around WordPress v3.

 Custom Post Types don't use the normal default category system, they use,
 essentially, a custom category, now, expected behaviour would be that the
 "cat=" parameter would work, because the system is still only looking for
 one type of category.

 However - as this area has been left untouched, that's not the case, and
 instead we have to do something much longer, like:


 {{{
                                         <?php
                                         $args = array(
         'post_type' => 'products',
         'tax_query' => array(
                 array(
                         'taxonomy' => 'product_category',
                         'field'    => 'example',
                         'terms'    => 'bob',
                 ),
         ),
 );
 $query = new WP_Query( $args );
                                         ?>
 }}}

 I think we need to get this changed, so that, if it is a custom post type,
 the cat= will look for the categories within that post type.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/33827#comment:1>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list