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 am using the following template for a custom post type. The pagination does not work as you can see at http://www.xava.ie/testimonials

Any hints as to why it is not working for me?

<?php
    global $paged;
    get_header();
    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; 
    $args = array(
        'post_type' => 'testimonials',
        'paged' => $paged,
        'posts_per_page' => 1
    );
    $products = new WP_Query( $args );
    if( $products->have_posts() ) {
        while( $products->have_posts() ) {
            $products->the_post();
            ?>
                <h1><?php the_title() ?></h1>
                <div class='content'>
                    <?php the_content() ?>

                </div>
            <?php
        }
        wp_pagenavi();
        echo "Number of post pages = ",$products->max_num_pages;
        if($products->max_num_pages>1){?>
                <p class="pager">
            <?php
            for($i=1;$i<=$products->max_num_pages;$i++){?>
                <?php $query_string = "?paged=".$i; ?>
                <a href="<?php echo $query_string; ?>" <?php echo ($paged==$i)? 'class="selected"':'';?>><?php echo $i;?></a>
            <?php }?>
            </p>
        <?php }         
    }
    else {
        echo 'Oh ohm no testimonials!';
    }       
    get_sidebar('Primary'); get_footer();
?>
share|improve this question
1  
Probably because you missed pre_get_posts. Search our site for better solutions. –  toscho May 9 '13 at 13:10
    
Do you have an English site? –  Amit Wadhwa May 9 '13 at 16:51
    
The last link in my profile points to the English site I am contributing to. Why is that relevant? :) –  toscho May 9 '13 at 16:53
    
You recommended that I search your site for better solutions. –  Amit Wadhwa May 17 '13 at 12:56
    
No, our site, WordPress Stack Exchange. –  toscho May 17 '13 at 12:57

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.