[wp-trac] [WordPress Trac] #33318: tax_query breaks certain other wp_query args

WordPress Trac noreply at wordpress.org
Thu May 26 06:06:52 UTC 2016

#33318: tax_query breaks certain other wp_query args
 Reporter:  djripraw           |       Owner:
     Type:  defect (bug)       |      Status:  new
 Priority:  normal             |   Milestone:  Awaiting Review
Component:  Query              |     Version:  4.2.4
 Severity:  normal             |  Resolution:
 Keywords:  reporter-feedback  |     Focuses:  template

Comment (by m_i_n):

 My previous code was example, but now i delete as much as i can
 unnecessary code from my real source and at the end i have this:

 register_post_type('portfolio', array(
         'public'       => true,
         'hierarchical' => true
 register_taxonomy('portfolio-category', 'portfolio', array(
         'hierarchical' => true

 $query = new \WP_Query(array(
         'posts_per_page'  => 2,
         'post_type'       => 'portfolio',
         'tax_query'       => array(
                         'taxonomy' => 'portfolio-category',
                         'field'    => 'term_id',
                         'terms'    => array(222)

 Result: `5` (should be 2).

 `public` and `hierarchical` doesn't change anything.

 When i delete `tax_query`: `2`.
 When i change terms in `tax_query` for non-existing term: `0`.
 When i change `post_type` to `post` (and properly adapt `tax_query`): `2`.

 I'm trying to run query in shortcode, in content, before header, after
 footer, and it also doesn't have matter.

 Sorry for my english ;)

Ticket URL: <https://core.trac.wordpress.org/ticket/33318#comment:7>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform

More information about the wp-trac mailing list