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.
<ul class="list">
<?php
    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    $args = array(
        'category'      => '8',
        'orderby'       => 'post_date',
        'order'         => 'DESC',
        'post_type'     => 'post',
        'post_status'       => 'publish',
        'posts_per_page'    => 9,
        'paged'         => $paged,
    );

    $postslist = get_posts( $args );
    foreach ($postslist as $post) :  setup_postdata($post);
?>
    <li>
        <h2><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h2>
    </li>
<?php endforeach; ?>
</ul>

<?php wp_paginate(); ?>
<?php wp_pagenavi(); ?>
<?php next_posts_link() ?>
<?php previous_posts_link() ?>

The code above successfully list the most recent 9 posts, however none the pagination works. I have installed WP-Paginate and WP-PageNavi plugins for testing.

share|improve this question
    
I'm sure there are several questions on this site dealing with this issue if you poke around. what sort of page are you using this on? pagination functions work with a page's main query, not custom queries within the template. –  Milo Mar 25 '13 at 19:27
    
I'm using this on a custom page template. –  sdcr Mar 25 '13 at 19:33
add comment

Your Answer

 
discard

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

Browse other questions tagged or ask your own question.