wp_reset_query()
函数用于重置WordPress的查询。在自定义查询或修改查询参数之后,你可能需要使用这个函数来重置到默认的查询。例如:
// 自定义查询
$args = array(
'post_type' => 'product',
'posts_per_page' => 10,
);
$custom_query = new WP_Query($args);
// 重置查询
wp_reset_query();
// 自定义查询
$args = array(
'post_type' => 'product',
'posts_per_page' => 10,
);
$custom_query = new WP_Query($args);
// 重置查询
wp_reset_query();
// 自定义查询 $args = array( 'post_type' => 'product', 'posts_per_page' => 10, ); $custom_query = new WP_Query($args); // 重置查询 wp_reset_query();