问题
I have a blog page that calls posts with tag 'blog'. So i called a custom WP_query() object: $blog = new WP_query('tag=blog');
.
The result works fine, but when i paginate the posts, the links always is shown even if doesn't exist more than 10 posts (the default limit).
How can i fix it?
回答1:
just add the following code
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
then you query will be like as following
$blog = new WP_query('tag=blog&posts_per_page=10&paged=' . $paged);
来源:https://stackoverflow.com/questions/23807474/how-to-paginate-a-custom-wp-query-loop-wordpress