I have tried to display products by tags on shop page, i found this code and it workes perfectly
$ args = array( 'number' => $ number, 'orderby' => 'title', 'order' => 'ASC', 'hide_empty' => $ hide_empty, 'include' => $ ids ); $ product_tags = get_terms( 'product_tag', $ args ); $ count = count($ product_tags); if ( $ count > 0 ){ foreach ( $ product_tags as $ product_tag ) { echo '<h4>' . $ product_tag->name . '</a></h4>'; $ args = array( 'posts_per_page' => -1, 'tax_query' => array( 'relation' => 'AND', array( 'taxonomy' => 'product_tag', 'field' => 'slug', // 'terms' => 'white-wines' 'terms' => $ product_tag->slug, 'product_tag'=> "latest-product" ) ), 'post_type' => 'product', 'orderby' => 'title,' ); $ products = new WP_Query( $ args ); woocommerce_product_loop_start(); while ( $ products->have_posts() ) { $ products->the_post(); do_action( 'woocommerce_shop_loop' ); wc_get_template_part( 'content', 'product' ); ?> <?php } woocommerce_product_loop_end(); } } ?>
But when I tried to filter resaults it wont apply filters, by the way i m using Annasta Filter Plugin