0

I don't get my pagination to work. I need to filter my posts on sticky posts and display only two per page. Tried almost everything but can't get it to work. It is totally ignoring my posts_per_page setting. Anyone got a suggestion?

<?php query_posts(array('posts_per_page' =>2, 'paged' => get_query_var('page'), 'post__in'=>get_option('sticky_posts'))); ?>

    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>

                <?php the_content(''); ?>

<?php endwhile; ?>

<?php else : ?>

<?php endif; ?>

    <span class="older"><?php next_posts_link('&laquo; Older Entries'); ?></span>
    <span class="newer"><?php previous_posts_link('Newer Entries &raquo;'); ?></span>
  • Got it <?php query_posts('posts_per_page=2' . '&paged=' . get_query_var('paged')); ?> <?php if (have_posts()) : ?> <?php while (have_posts()) : the_post(); ?> – AKNL Oct 14 '11 at 19:49
  • Please move your solution to an answer so this doesn't haunt site as unanswered. – Rarst Oct 14 '11 at 21:31
  • fixed it, sorry for that – AKNL Oct 16 '11 at 8:36
2

Got it

<?php 
    query_posts('posts_per_page=2' . '&paged=' . get_query_var('paged')); 
    if (have_posts()) : ?> <?php while (have_posts()) : the_post(); 
?>

as simple as that.

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.