-1

http://dthudson.com/ccr/archive-issues/

The paginated pages are being populated by the content as you can see at the bottom (beneath the posts) but when you click on '2' for instance it loads page 2 but it shows the exact same posts. I want to point out that I am using Advanced Custom Fields to retrieve content from the post-type 'issues', I wonder if this is contributing to the problem. Also - I copied the pagination code from my index page and search page and each of those works fine. Any ideas?

<!-- BEGIN LOOP -->         

<?php 

$args = array(
        'post_type' => 'issues',
        'posts_per_page' => '9',
        'order' => 'ASC',
        'orderby' => 'meta_value_num'
);

$my_query = new WP_Query( $args );


if ($my_query->have_posts()) : while ($my_query->have_posts()) : $my_query->the_post();?>

            <div class="loop four columns hover-issue">
                <div class="column-nest">
                    <a class="hover-color" href="<?php echo get_permalink(); ?>"><h5 class="staff-title big-top-space"><?php the_field('release_season'); ?> <?php the_field('release_year'); ?></h5>
                    <h6 class="staff-name  bottom-space"><?php the_field('issue_number_full_length'); ?></h6></a>               
                </div> <!-- column-nest -->
                <figure class="staff-photo-border">
                    <a href="<?php echo get_permalink(); ?>"><img class="column-nest image-width" src="<?php the_field('issue_image_cropped'); ?>" alt="photo of issue <?php the_field('issue_number'); ?>" /></a>
                </figure> <!-- staff-photo-border -->
            </div> <!-- loop four columns -->


<?php the_content(); ?>
<?php endwhile; endif; ?>

        </div> <!-- looper twelve columns -->

                    <nav class="pagination">

                        <?php

                        $total_pages = $my_query->max_num_pages;  

                        if ($total_pages > 1){  

                          $current_page = max(1, get_query_var('paged'));  

                          echo paginate_links(array(  
                              'base' => get_pagenum_link(1) . '%_%',  
                              'format' => 'page/%#%',  
                              'current' => $current_page,  
                              'total' => $total_pages, 
                              'prev_next'    => False,
                              'type' => 'list', 
                            ));  
                        }  
                        ?>

       </nav><!--end pagination-->  
2
  • 1
    you don't pass a paged argument to your query.
    – Milo
    Commented Mar 10, 2014 at 23:39
  • @milo hi thanks for the tip - I read through the documentation and I'm still struggling with where to go with this. any suggestions? Commented Mar 11, 2014 at 2:03

1 Answer 1

0

Your query displays the first 9 posts regardless of page because you don't set the page number in your query arguments.

$paged = ( get_query_var('paged') ) ? get_query_var('paged') : 1;
$args = array(
    'post_type' => 'issues',
    'posts_per_page' => '9',
    'order' => 'ASC',
    'paged' => $paged
);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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