Foward / back button on single custom post types not working
-
So, I’m having a really hard time with getting “previous” and “next” buttons to work they way they should on my custom post types on my site.
I can get them to sort of work with the following code, but once it reaches a certain post, you can only cycle back and forth between two posts. Really stuck on this. I think it has something to do with the loop, and where it ends, but I have no idea. Can someone please take a look and help me out? Would be greatly appreciated.
<div class="navigation"> <?php previous_post(); ?> <?php next_post(); ?> </div>
I tried tons of variations of that, and just to get it so that when you get to the last post, there is no “next” but it always seems to display the other posts and from there you can only cycle back and forth between the two. So weird.
Here’s the rest of the page code, if that helps:
<?php if (have_posts()): while (have_posts()): the_post(); ?> <div <?php post_class() ?> id="post-<?php the_ID(); ?>"> <h1 style="margin-top: 10px;"><?php the_title(); ?></h1> <div class="navigation"> <?php previous_post(); ?> <?php next_post(); ?> </div> <div style="width: 200px;" class="alignright"> <?php //set vars $lot_size = get_post_meta( $post->ID, 'lot_size', true ); $pricing = get_post_meta( $post->ID, 'pricing', true ); $available = get_post_meta( $post->ID, 'available', true ); ?> <?php if ($lot_size) : ?> <p id="lot-size"><strong>Lot Size: </strong><?php echo $lot_size; ?></p> <?php endif; ?> <?php if ($pricing) : ?> <p id="pricing"><strong>Pricing:</strong> <?php echo $pricing; ?></p> <?php endif; ?> <?php if ($available) : ?> <p id="available"><strong>Availability:</strong> <?php echo $available; ?></p> <?php endif; ?> </div> <?php if ( has_post_thumbnail()) : ?> <?php the_post_thumbnail('medium'); ?> <?php endif; ?> <?php the_content(); ?> </div> <p class="postmetadata"> <?php the_terms( $post->ID, 'category', 'Filed In: ', ' <span style="color:#000">/</span> ', '' ); ?> <?php edit_post_link('Edit', '', ' | '); ?> <?php ?> </p> <?php endwhile; else: ?> <h2 class="center">No Posts Yet, Please Stay Tuned...</h2> <?php get_search_form(); ?> <?php endif; ?>
- The topic ‘Foward / back button on single custom post types not working’ is closed to new replies.