tax_query in get_posts() not working?

tax_query takes an array of tax query arguments arrays (it takes an array of arrays) but you are using only single array. The correct code is as following. $uposts = get_posts( array( ‘post_type’ => ‘product’, ‘numberposts’ => -1, ‘tax_query’ => array( array( ‘taxonomy’ => $cat->taxonomy, ‘field’ => ‘slug’, ‘terms’ => array($cat->slug), ‘operator’ => ‘IN’, ) … Read more

WordPress tax_query “and” operator not functioning as desired

not tested but give this a shot ‘tax_query’ => array( ‘relation’ => ‘AND’, array( ‘taxonomy’ => ‘image_tag’, ‘field’ => ‘term_id’, ‘terms’ => 25, ‘operator’ => ‘IN’, ), array( ‘taxonomy’ => ‘image_tag’, ‘field’ => ‘term_id’, ‘terms’ => 41, ‘operator’ => ‘IN’, ) ), OR ‘tax_query’ => array( ‘relation’ => ‘AND’, array( ‘taxonomy’ => ‘image_tag’, ‘field’ => … Read more

“tax_query” parameter not working with WP_Query

The tax_query parameter is an array of arrays, not just an array. This: ‘tax_query’ => array( ‘taxonomy’ => ‘video_type’, ‘terms’ => ‘episode’, ‘field’ => ‘slug’, ‘include_children’ => true, ‘operator’ => ‘IN’ ), Should instead be this: ‘tax_query’ => array( array( ‘taxonomy’ => ‘video_type’, ‘terms’ => ‘episode’, ‘field’ => ‘slug’, ‘include_children’ => true, ‘operator’ => ‘IN’ … Read more

Nested meta_query with multiple relation keys

The question was for WordPress 3.0, but just in case someone has the same question for a more recent version, from WordPress Codex: “Starting with version 4.1, meta_query clauses can be nested in order to construct complex queries.” https://developer.wordpress.org/reference/classes/wp_query/#custom-field-post-meta-parameters So, that query should work on the current WordPress version.