WP Tax query & order by tax query not working

Here’s an example of working tax_query. The problem I’ve run into with tax_query is forgetting to nest the array (i.e. ‘tax_query’ is array(array(…)). If you don’t do that, it does not work. $args = array( ‘post_type’ => $post_type, ‘posts_per_page’ => -1, //show all posts ‘tax_query’ => array( array( ‘taxonomy’ => $taxonomy, //’field’ => ‘slug’, //’terms’ … Read more

Multiple Taxonomy post query with exclusion

If I understood you correctly, an array of terms either slug or term_id, for example, depending on field to be exact. $args = array( ‘post_type’ => ‘a_post_type’, ‘tax_query’ => array( ‘relation’ => ‘AND’, array( ‘taxonomy’ => ‘tax_one’, ‘field’ => ‘slug’, ‘terms’ => array( ‘action’, ‘comedy’ ), ), array( ‘taxonomy’ => ‘tax_two’, ‘field’ => ‘term_id’, ‘terms’ … Read more

Taxonomy archive, categorised by other taxonomy, not hiding empty taxonomies

1) Fixing this was surprisingly simple – I wrapped the category name request in if have_posts and that got rid of the empty values 2) I had to include a secondary loop using ‘operator’ => ‘NOT IN’ to list the treatments that were not in a taxonomy. I am sure there is a leaner and … Read more

WordPress multiple loops with default pagination

try now this code <?php $paged = ( get_query_var( ‘paged’ ) ) ? get_query_var( ‘paged’ ) : 1; $title = get_term_by(‘slug’, get_query_var(‘term’), get_query_var(‘taxonomy’) ); $args = array( ‘post_type’ => ‘suppliers’, ‘tax_query’ => array( array( ‘taxonomy’ => ‘ad_category’, ‘field’ => ‘slug’, ‘terms’ => array(‘basic_advertiser’), ), array( ‘taxonomy’ => ‘supplier_categories’, ‘field’ => ‘slug’, ‘terms’ => $title->slug, ), … Read more