×

Welcome to TagMyCode

Please login or create account to add a snippet.
0
0
 
0
Language: PHP
Posted by: Web Designer
Added: Oct 18, 2017 11:20 AM
Views: 11
URL to previous / next post in the same taxonomy with Post Title for text.
  1.     <?php $prev_post = get_adjacent_post( true, '', true, 'taxonomy_slug' ); ?>
  2.     <?php if ( is_a( $prev_post, 'WP_Post' ) ) { ?>
  3.         <a href="<?php echo get_permalink( $prev_post->ID ); ?>"><?php echo get_the_title( $prev_post->ID ); ?></a>
  4.     <?php } ?>
  5.  
  6.     <?php $next_post = get_adjacent_post( true, '', false, 'taxonomy_slug' ); ?>
  7.     <?php if ( is_a( $next_post, 'WP_Post' ) ) { ?>
  8.         <a href="<?php echo get_permalink( $next_post->ID ); ?>"><?php echo get_the_title( $next_post->ID ); ?></a>
  9.     <?php } ?>