0

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!

Community
  • 1
  • 1
user2151960
  • 185
  • 1
  • 1
  • 17

1 Answers1

2

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 );
doublesharp
  • 26,888
  • 6
  • 52
  • 73