Reputation: 94
Similar questions have been asked but none seem to apply to my situation here. I have two custom post-types built into a WP site. I created single-first_one.php to capture each of the first post-types. It works perfectly and the pagination I added works also.
The second post-type, I created single-second_one.php, and on this 'single' page, I'm displaying the current post, as well as below, the most recent 6 posts. Everything is showing as it should except my pagination links (in the single-second_one.php). The code is almost identical to that of the first 'single' template so I don't understand why it's not working. Any help?
<?php get_header(); ?>
<h1>Events</h1>
<section id=featured_post>
<?php $paged = (get_query_var('paged') && get_query_var('paged') > 1) ? get_query_var('paged') : 1; ?>
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<h5 class=previous><?php previous_post_link('%link'); ?></h5>
<h5 class=next><?php next_post_link('%link'); ?></h5>
<article class="post-<?php the_ID(); ?>">
<div>
<?php if ( has_post_thumbnail()) : ?>
<?php the_post_thumbnail(); ?>
<?php endif; ?>
</div>
<h2><?php the_title(); ?></h2>
<h3><?php the_time('l F j'); ?></h3>
<?php the_content(); ?>
</article>
<?php endwhile; ?>
<?php else: ?>
<?php endif; ?>
<?php wp_reset_query(); ?>
</section>
<h1>Upcoming Events</h1>
<section id=other_posts>
<?php
$args = array('post_type' => 'event', 'showposts' => 6, 'order' => 'ASC', 'post_status' => 'future');
$loop = new WP_Query($args);
if ( have_posts() ) : while ( $loop->have_posts() ) : $loop->the_post();?>
<article class="post-<?php the_ID(); ?>">
<h2><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h2>
<h3><?php the_time('l F j'); ?></h3>
<?php html5wp_excerpt('events_page_listing'); ?>
</article>
<?php endwhile; else: ?>
<?php endif; ?>
</section>
I've gone to Options -> Permalinks, cached everything, taken out the second half section that calls the six recent posts, taken out single-first_one.php altogether, and nothing works. The 's for pagination on the second single page are empty.
EDIT
I've tried moving the next/previous calls around, after the endwhile, between endwhile and else, etc. Nothing is working. It's so bizarre because on the other single.php page, everything is setup the EXACT same way and is showing the next/prev posts links perfectly.
EDIT
I added the pagination argument but it's still not working.
Upvotes: 0
Views: 1086
Reputation: 15969
You do not have any pagination arguments in the code ..
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$args = array(
'posts_per_page' => 3,
'paged' => $paged
);
or
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
query_posts('posts_per_page=3&paged=' . $paged);
or also something like
$paged = (get_query_var('paged') && get_query_var('paged') > 1) ? get_query_var('paged') : 1;
Upvotes: 0