Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/wordpress/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 品牌和类别产品的woocommerce短代码_Php_Wordpress_Woocommerce_Shortcode_Wordpress Shortcode - Fatal编程技术网

Php 品牌和类别产品的woocommerce短代码

Php 品牌和类别产品的woocommerce短代码,php,wordpress,woocommerce,shortcode,wordpress-shortcode,Php,Wordpress,Woocommerce,Shortcode,Wordpress Shortcode,我想展示特定类别和品牌的所有产品。例如,我有类别boiler和品牌Ariston。有没有办法只显示阿里斯顿的锅炉?您可以这样做: $loop = new WP_Query( array( 'post_type' => 'product', 'posts_per_page' => -1, 'orderby' => 'date',

我想展示特定类别和品牌的所有产品。例如,我有类别
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 category=“Ariston,boiler”cat_operator=“AND”]

是的,但我只需要锅炉,而不需要亚里士多德的所有东西。你如何在你的店里使用“品牌”?另一类?属性?变体?正如我所说,我需要一个短代码,而不是循环。