Wordpress Woocommerce在当前类别中的所有产品之后显示其他类别

Wordpress Woocommerce在当前类别中的所有产品之后显示其他类别,wordpress,plugins,woocommerce,categories,product,Wordpress,Plugins,Woocommerce,Categories,Product,是否有一个插件或一些代码,在打开某个类别和所有产品后显示,以显示其他类别的产品。因为某些类别或子类别只有2-4个产品,我想用其他类别的产品来填充页面 例子:手套 手套页标题 2-4种产品 然后是一些5-6款产品的靴子 谢谢 简单的方法是创建多个类别,例如“服装”类别,并将手套和靴子都分配给它。更复杂的方法可能是使用生成列表 $args = array( 'post_type' => 'product', 'posts_per_page' => 9, 'tax_

是否有一个插件或一些代码,在打开某个类别和所有产品后显示,以显示其他类别的产品。因为某些类别或子类别只有2-4个产品,我想用其他类别的产品来填充页面

例子:手套

手套页标题

2-4种产品

然后是一些5-6款产品的靴子


谢谢

简单的方法是创建多个类别,例如“服装”类别,并将手套和靴子都分配给它。更复杂的方法可能是使用生成列表

$args = array(
    'post_type' => 'product',
    'posts_per_page' => 9,
    'tax_query' => array(
        'relation' => 'OR',
        array(
            'taxonomy' => 'product_cat',
            'field' => 'slug',
            'terms' => 'my-glove-category'
        ),
        array(
            'taxonomy' => 'product_cat',
            'field' => 'slug',
            'terms' => 'my-boots-category'
        )
    )
);

$executedQuery = new WP_Query($args);
if ($executedQuery->have_posts()) {
    while ($executedQuery->have_posts()) {
        $executedQuery->the_post(); //increment the post pointer, getting us the next post in the list
        echo '<h2>' . get_the_title() . '</h2>';
    }
}
else {
    echo 'No products were found.';
}
$args=array(
“post_类型”=>“产品”,
“每页帖子数”=>9,
“tax_query”=>数组(
'关系'=>'或',
排列(
“分类法”=>“产品分类”,
'字段'=>'段塞',
“术语”=>“我的手套类别”
),
排列(
“分类法”=>“产品分类”,
'字段'=>'段塞',
“术语”=>“我的靴子类别”
)
)
);
$ExecuteQuery=新的WP\U查询($args);
如果($executedQuery->have_posts()){
而($executedQuery->have_posts()){
$ExecuteQuery->the_post();//增加post指针,为我们提供列表中的下一篇文章
回显“”。获取标题();
}
}
否则{
echo“未发现任何产品”;
}
此示例将获取
我的手套类别
我的靴子类别
中的所有产品。如果你想按类别分类,那就变得有点难了

您还可以使用
product\u标签
作为这些查询的分类法,请参阅