I have a page with the most rated posts.
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?
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)
Thank you!
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 );
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.