Query posts by taxonomy term name

I’m not sure if the get_posts function supports the tax_query. You might want to try creating a new WP_Query object instead.

$args = array(
'tax_query' => array(
    array(
        'taxonomy' => 'store',
        'field' => 'name',
        'terms' => $mystorename
        )
    )
);

$query = new WP_Query($args);
if ( $query -> have_posts() ) : while ( $query -> have_posts() ) : $query -> the_post(); ?>
    <!-- post -->
<?php endwhile; ?>
    <!-- post navigation -->
<?php else: ?>
    <!-- no posts found -->
<?php endif; ?>

Leave a Comment