您需要在$args数组中设置分页的arg:
$listing_args = array(
\'post_type\' => \'business\',
\'posts_per_page\' => 10,
\'meta_key\' => \'listing_num\',
\'orderby\' => \'meta_value_num\',
\'order\' => \'DESC\',
\'offset\' => ($paged -1) * 10,
\'paged\' => $paged, // <- tell the query what page we are on.
\'tax_query\' => ......etc
);
然后使用
pageinate_links
作用
https://codex.wordpress.org/Function_Reference/paginate_links 填充指向下一页/上一页的链接。
codex中关于如何将其用于自定义查询的示例:
$big = 999999999; // need an unlikely integer
echo paginate_links( array(
\'base\' => str_replace( $big, \'%#%\', esc_url( get_pagenum_link( $big ) ) ),
\'format\' => \'?paged=%#%\',
\'current\' => max( 1, get_query_var(\'paged\') ),
\'total\' => $the_query->max_num_pages
) );