So I have a page on my site for press releases, and the press releases are a custom post type. I'm using a custom template called page-press.php for the Press page, and I want to display a loop of the recent posts for this post type in it.

All is well there. However, when I set the posts_per_page argument to a value that should trigger pagination, I'm not getting the pagination.

I think it must have to do with where I'm calling for the pagination in relationship to the loop, perhaps, or the order of my if else logic, but I've been looking at this for so long I think I'm probably just missing the obvious by now.

Here's teh codez:

<div class="content">
<?php if ( have_posts() ) : ?>

    <?php /* Start the Loop */ ?>
    <?php while ( have_posts() ) : the_post(); ?>

    <?php the_content(); ?>

    <?php endwhile; ?>

    <!-- start listing the posts -->
    <?php $a2_press_query = new WP_Query( array ( 'post_type' => 'a2_press', 'posts_per_page' => 2)); ?>
    <?php while ( $a2_press_query->have_posts() ) : $a2_press_query->the_post(); ?>
    <article class="post <?php the_ID();?>" id="post-<?php the_ID();?>">
            <h3><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3>
            <p class="post-date"><span class="month"><?php the_time('M') ?></span> <span class="day"><?php the_time('d') ?></span> <span class="year"><?php the_time('Y') ?></span></p>
        <div class="post-content">
            <?php the_excerpt(); ?>
            <p><a href="<?php the_permalink(); ?>" title="Read the whole post" rel="nofollow" class="button small muted read-more">Read more <em>&rarr;</em></a></p>
    <?php endwhile;
    // Reset Post Data
    wp_reset_postdata(); ?>

    <div class="item-list">
        <ul class="pager">
        <?php get_pagination(); ?>

    <?php else : ?>

    <div class="entry-content">
        <p><?php _e( 'Apologies, but no results were found. Perhaps searching will help find a related post.', 'appendto-2012' ); ?></p>
        <?php get_search_form(); ?>
    </div><!-- .entry-content -->

<?php endif; // end have_posts() check ?>

Why isn't the pagination being generated from this?

Note: everything else is working properly - it is displaying my posts from this category on the page.


Pagination is only built "well" in non-custom post-types. Below, I'll post an article with more detail about the more complex setup required for custom post-type pagination via the WP_Query() method.

But to give the direct answer to your question, it's not working because get_pagination() is not a method that belongs to the WP_Query() object, rather it belongs to the native WordPress loop and is inaccessible as you have it coded in your question. To set it up properly, see this article:


  • Awesome - thanks for the link Brian. I'll check it out. Nov 5 '12 at 21:24
  • No prob - not sure if you're a regular stack overflower, but don't forget to mark the answer accepted if it's what you're looking for so that anyone who sees this later will know how to resolve their issue if they have the same problem.
    – Brian
    Nov 5 '12 at 22:39
  • Yeah, I appreciate the link, and the explanation, but I'm hoping to see an answer that shows me how I can fix my existing beyond just a link to a reference. But thanks just the same, Brian. Nov 6 '12 at 1:25
  • LOL, there's alot of code that yo need to change in order to get it working as you're hoping. If you like, I can copy and paste it from the article into my response...
    – Brian
    Nov 6 '12 at 16:24
  • Sad part is, I spent several hours yesterday trying to work through that, and extract the solution from the article (partly because the scenario is a bit different for me), and now I'm on to trying to resolve another issue. I'm working on a port of an entire site built in Drupal over to Wordpress. Nov 6 '12 at 16:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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