【发布时间】:2018-12-17 05:23:40
【问题描述】:
我有一个设置为目录可见性的 WooCommerce 产品:隐藏我想从我的 WP_Query 中排除这些类型的产品。我怎样才能做到这一点?这是我获取所有产品的代码
<?php
$args = array(
'post_type' => 'product',
'posts_per_page' => -1,
);
$query = new WP_Query( $args );
?>
<?php if($query->have_posts()): ?>
<ul>
<?php while( $query->have_posts() ): $query->the_post(); ?>
<?php $product = wc_get_product(get_the_ID());?>
<li><a href="<?php the_permalink(); ?>"><?php echo $product->get_sku(); ?></a></li>
<?php endwhile; ?>
</ul>
<?php endif; ?>
【问题讨论】:
标签: wordpress woocommerce