I'm trying to add paging to the query below. However, I can't seem to get the paging to work. It shows previous/next links, however, they always show the same 2 posts. There are 8 posts in this query.

//$paged = get_query_var( 'page' );

global $post;

$args = array('posts_per_page' => 2,'paged'=>1);
$posts = get_posts($args);
  • You are overwriting any pagination variables with 'paged' => 1, it's not a boolean flag but the current page indicator. – Horacio Nuñez Apr 23 '12 at 18:08

If you make paged equal to get_query_var( 'paged' ) that should do the trick. You may need to do something like $paged = get_query_var( 'paged' ) ? get_query_var( 'paged' ) : 1; and then set paged to $paged.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.