展开全部
第一步,参考你给的网址,创建页面及62616964757a686964616fe4b893e5b19e31333363386137模板
第二步,在你的页面模板文件的循环内部,添加如下代码:$product_category = array('上衣', '裤子', '鞋子');
foreach ($product_category as $key => $category) {
$products = wc_get_products( array(
'status' => array('publish'),
'limit' => 0,
'category' => array( $category )
) );
//var_dump($products);
// html输出
if ( count($products) ) :
printf( '
%s
', $category);foreach ($products as $key => $product) {
printf('
%s
', get_the_title( $product->id ) );}
endif;
}