Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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>
share|improve this question
    
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
add comment

1 Answer

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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