Wordpress 如何在woocommerce存档产品页面上按标签或类别显示产品

Wordpress 如何在woocommerce存档产品页面上按标签或类别显示产品,wordpress,woocommerce,Wordpress,Woocommerce,请帮助我自定义我的woocommerce产品循环,以按标签或类别显示产品。我在存档产品页面上的自定义循环如下所示,它排除了一个类别: <?php $product = new WC_Product(get_the_ID()); $params = array('posts_per_page' => 12, 'post_type' => 'product', 'tax_query' => array(

请帮助我自定义我的woocommerce产品循环,以按标签或类别显示产品。我在存档产品页面上的自定义循环如下所示,它排除了一个类别:

<?php
                $product = new WC_Product(get_the_ID());
                $params = array('posts_per_page' => 12, 'post_type' => 'product', 'tax_query' => array(
        array(
            'taxonomy' => 'product_cat',
            'field' => 'slug',
            'terms' => array( 'free' ),
            'operator' => 'NOT IN'
        )
    ));
                $wc_query = new WP_Query($params);
                ?>
                <?php if ($wc_query->have_posts()) : ?>
                <?php while ($wc_query->have_posts()) :
                $wc_query->the_post(); ?>
                <article class="portfolio__item portfolio__item--shop">
                    <figure class="blog__image-container">
                        <?php if ( has_post_thumbnail()) {the_post_thumbnail('thumb-blog' ,array("class"=>"portfolio__image post_thumbnail"));} ?>
                    </figure>
                    <h3 class="portfolio__content-title portfolio__content-title--shop"><?php the_title(); ?></h3>
                    <p class="portfolio__content-text portfolio__content-text--shop"><?php $product = new WC_Product(get_the_ID()); echo $product->get_price_html(); ?></p>
                        <div class="portfolio__content">
                            <img class="portfolio__content-image" src="<?php echo get_template_directory_uri(); ?>/img/link-loop.png" alt="" data-jslghtbx="<?php
                                $thumb_id = get_post_thumbnail_id();
                                $thumb_url = wp_get_attachment_image_src($thumb_id,'thumb-big', true);
                                echo $thumb_url[0];
                            ?>">
                            <a href="?add-to-cart=<?php echo $product->id; ?>" class="portfolio__link">
                                <p class="portfolio__content-text">Click to buy</p>
                            </a>
                        </div>

                </article>
                <?php endwhile; ?>

它就在这里 我需要这个页面按标签排序,但现在它显示所有产品