SO网友:Brooke.
参见Adding the $paged Parameter to a query 在法典中。您将需要执行以下操作:
$paged = (get_query_var(\'paged\')) ? get_query_var(\'paged\') : 1; //or use the global $paged
$args = array(
\'post_type\' => array( \'post\', \'videos\', \'music\' ),
\'posts_per_page\' => -1, //-1 for all post that match query
\'paged\' => $paged, //get current page
\'tax_query\' => array(
array(
\'taxonomy\' => \'content\',
\'field\' => \'slug\',
\'terms\' => \'indy\',
\'operator\' => \'NOT IN\'
)
)
);
//loop code
然而,正如Chris所说,它只适用于主查询,因此您需要执行以下操作:
$temp = $wp_query; //save the main loop query for later use
$wp_query= null; //set the current query to null
$wp_query = new WP_Query($args); //get your args
//do some sweet loop action
$wp_query = null; //set custom query to null
$wp_query = $temp; //rest main query back to the way things were
wp_reset_query(); //reset the main query
查看此问题或google自定义查询不使用分页查找
this same solution 在其他网站上。