品牌和类别产品的 woocommerce 简码

woocommerce shortcode for products in brand and category

我想显示特定类别和品牌的所有产品。例如,我有类别 boiler 和品牌 Ariston。有没有办法只显示阿里斯顿的锅炉?

你可以这样做:

$loop = new WP_Query(
            array(
                'post_type' => 'product',
                'posts_per_page' => -1,
                'orderby' => 'date',
                'order'   => 'DESC',
                'category_name' => 'Ariston'
            )
        );

然后,你可以读循环:

 <?php while ($loop->have_posts()) : $loop->the_post(); ?>
            
         <div>
             <?php echo get_the_title(); ?> - <?php echo get_the_content(); ?>
         </div>

         <?php endwhile; ?>

然后,您可以按照自己的方式使用结果。

我希望我已经让自己明白了。

如果您的品牌也在该类别下,您可以使用 [products] 然后按照以下代码操作:

[products category="Ariston,boiler" cat_operator="AND"]