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();?>">
<header>
<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>
</header>
<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>→</em></a></p>
</div>
</article>
<?php endwhile;
// Reset Post Data
wp_reset_postdata(); ?>
<div class="item-list">
<ul class="pager">
<?php get_pagination(); ?>
</ul>
</div>
<?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 ?>
</div><!--/.content-->
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.