【发布时间】:2021-01-09 17:15:37
【问题描述】:
我有一个数组,其中包含几个产品 SKU 我想展示连接到 SKU 的产品。
我找到了自定义 woocommerce 产品循环,但找不到任何关于如何扩展它的文档。
$skus = array(sku1, sku2, sku3);
$args = array(
'post_type' => 'product',
'post_status' => 'publish',
'posts_per_page' => -1,
);
$loop = new WP_Query( $args );
if ( $loop->have_posts() ) {
while ( $loop->have_posts() ) : $loop->the_post();
wc_get_template_part( 'content', 'product' );
endwhile;
}
wp_reset_postdata();
【问题讨论】:
标签: php wordpress loops woocommerce product