Wordpress-页面分页
问题描述:
我的页面上的帖子评分最高.
I have a page with the most rated posts.
我使用WP-PostRatings,并且使用以下代码:
I use WP-PostRatings and I use this code:
query_posts( array( 'meta_key' => 'ratings_average', 'orderby' => 'meta_value_num', 'order' => 'DESC' ) );
是否可以为页面创建分页?
Is there a way to create pagination for pages?
我在这里找到了包含静态页面的Wordpress分页,但它向我展示了所有页面,最新帖子,按日期排序(如在首页中一样)
I found something here Wordpress pagination with static pages , but it shows me in all pages, the newest posts, order by date (as in homepage)
谢谢!
答
要获取与之配合使用的分页query_posts()
,您需要将$paged
变量添加到您的查询:
To get pagination to work with query_posts()
you need to add the $paged
variable to your query:
$posts_per_page = 10;
$paged = ( get_query_var('paged') ) ? get_query_var('paged') : 1;
$query = array(
'meta_key' => 'ratings_average',
'orderby' => 'meta_value_num',
'order' => 'DESC',
'posts_per_page' => $posts_per_page,
'paged' => $paged
);
query_posts( $query );