I'm having trouble with getting tax_query to act as a filter for posts. What I would like is to have it so it will display cpt's that have the terms of county and status but also work if terms are not provided for status or county. So have the posts show if it has the term of "Adams" county in the County taxonomy and the the term of "Locked" in the Status taxonomy. But it needs to also work if a County is not provided, just a status and vice-versa.
Here is my code:
<?php $args = array( 'post_type' => 'property', 'posts_per_page' => 5000, 'tax_query' => array( 'relation' => 'AND', array( 'taxonomy' => 'Status', 'field' => 'slug', 'terms' => explode( ',', $st_term_final_string ) ), array( 'taxonomy' => 'County', 'field' => 'slug', 'terms' => explode( ',', $il_term_final_string ) ) ) ); $loop = new WP_Query( $args ); while ( $loop->have_posts() ) : $loop->the_post(); the_title(); echo '<div class="entry-content">'; echo get_the_post_thumbnail(); the_content(); echo '</div>'; endwhile; ?>
Any hints to put me in the right direction?
Thanks in advance