I am trying to retrieve all the post associated with my custom taxonomy term. My custom taxonomy is “Stores”. I am using the following code.
$posts = get_posts(array( 'post_type' => 'coupon', 'numberposts' => -1, 'post_status' => array('publish', 'unreliable', 'draft'), 'tax_query' => array( array( 'taxonomy' => 'stores', 'field' => 'name', 'terms' => 'New Store', 'include_children' => false ) ) ));
My taxonomy term name is “New Store”. Just because it has a space in the title I couldn’t get any posts associated with it. I tried the same code on a taxonomy term without a space in the title and it worked.
Any help will be appreciated. Thanks.
Read more here: Get Posts via Taxonomy Term Name with Space