WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

    global $paged;
    $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() ) {
                <h1><?php the_title() ?></h1>
                <div class='content'>
                    <?php the_content() ?>

        echo "Number of post pages = ",$products->max_num_pages;
                <p class="pager">
                <?php $query_string = "?paged=".$i; ?>
                <a href="<?php echo $query_string; ?>" <?php echo ($paged==$i)? 'class="selected"':'';?>><?php echo $i;?></a>
            <?php }?>
        <?php }         
    else {
        echo 'Oh ohm no testimonials!';
    get_sidebar('Primary'); get_footer();
share|improve this question
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


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

Browse other questions tagged or ask your own question.