【发布时间】:2016-03-08 16:11:26
【问题描述】:
查看某个产品时,我正在显示最新产品。查看产品时,它仍会在底部显示为“最近的产品”。
<ul class="products">
<?php
$args = array(
'post_type' => 'product',
'posts_per_page' => 3,
'post__in' => $related,
);
$loop = new WP_Query( $args );
if ( $loop->have_posts() ) {
while ( $loop->have_posts() ) : $loop->the_post();
wc_get_template_part( 'content', 'product' );
endwhile;
} else {
echo __( 'No products found' );
}
wp_reset_postdata();
?>
我尝试使用 'post__not_in' => array($product->id) ,但它不起作用。
如何从最近的产品循环中隐藏我正在查看的产品?
【问题讨论】: