[wp-trac] [WordPress Trac] #29416: WP_Query tax_query :: terms array with one item doesn't query properly

WordPress Trac noreply at wordpress.org
Thu Aug 28 14:21:22 UTC 2014


#29416: WP_Query tax_query :: terms array with one item doesn't query properly
--------------------------+-----------------------------
 Reporter:  robertark     |      Owner:
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  Query         |    Version:  3.9.2
 Severity:  normal        |   Keywords:
  Focuses:                |
--------------------------+-----------------------------
 Consider this simple query:


 {{{
 $products = new WP_Query(
   array(
     'post_type' => 'product',
     'posts_per_page' => -1,
     'orderby' => 'date',
     'order' => 'DESC',
     'meta_query' => array(
       array(
         'key' => 'active',
         'compare' => '=',
         'value' => 'Yes'
       )
     ),
     'tax_query' => array(
       array(
         'taxonomy' => 'product_type',
         'field' => 'slug',
         'terms' => array('accessories'),
         'operator' => 'NOT IN'
       )
     )
   )
 );
 }}}

 When tax_query[terms] is an array with a single element, this tax_query
 has no effect. When I take 'accessories' out of the array, it works as
 expected. It would make sense to allow an array as the operator 'NOT IN'
 basically means 'item NOT IN array', not necessarily 'item NOT IN item'.

 Per the documentation:
 http://codex.wordpress.org/Class_Reference/WP_Query#Taxonomy_Parameters
 * terms can accept: int/string/array

 However, it does not list any limitations when accounting for number of
 items to test against.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/29416>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list