我对此感到困惑,所以我举个例子:
<ul class="prod">
<?php $woop = new WP_Query($wol);
while ( $woop->have_posts() ) : $woop->the_post(); global $prod; ?>
<h3><?php the_title(); ?></h3>
<?php woocommerce_template_loop_add_to_cart( $woop->post, $prod );?>
<?php endwhile; wp_reset_postdata();?>
</ul>
Run Code Online (Sandbox Code Playgroud)
在这个例子中,我应该使用wp_reset_query()还是wp_reset_postdata()?
我的理解是,我必须wp_reset_postdata()在每次自定义WP_Query()和wp_reset_query()每次循环后使用query_posts().
就这么简单吗?