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();