-
-
Save kagaim/6945169c0eeb011ca44f5e76c7409483 to your computer and use it in GitHub Desktop.
WordPress Pagination on single.php from the same category and/or taxonomy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div id="pagination"> | |
<?php | |
$prev_post = get_previous_post(true, '', 'taxonomy'); | |
$next_post = get_next_post(true, '', 'taxonomy'); | |
?> | |
<?php if (!empty( $prev_post )): ?> | |
<div class="prev"> | |
<a href="<?php echo get_permalink( $prev_post->ID ); ?>"> | |
<div class="title"><?php echo get_the_title($prev_post); ?></div> | |
</a> | |
</div> | |
<?php endif; ?> | |
<?php if (!empty( $next_post )): ?> | |
<div class="next"> | |
<a href="<?php echo get_permalink( $next_post->ID ); ?>"> | |
<div class="title"><?php echo get_the_title($next_post); ?></div> | |
</a> | |
</div> | |
<?php endif; ?> | |
</div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment