Last active
December 10, 2017 16:48
-
-
Save ozamancse/d493da6dea5aa670d2bb132a16b67f7b to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| //Use If else Condition | |
| <ul> | |
| <?php if (get_adjacent_post(false, '', true)): // if there are older posts ?> | |
| <li class="prev"><?php previous_post_link('%link', '« Previous post', TRUE); ?></li> | |
| <?php endif; ?> | |
| <?php if (get_adjacent_post(false, '', false)): // if there are newer posts ?> | |
| <li class="next"><?php next_post_link('%link', 'Next post »', TRUE); ?></li> | |
| <?php endif; ?> | |
| </ul> | |
| //Use Variable if else condition | |
| <?php | |
| $previous_post = get_adjacent_post(false, '', true); | |
| $next_post = get_adjacent_post(false, '', false); | |
| ?> | |
| <ul> | |
| <?php if ($previous_post): // if there are older articles ?> | |
| <li class="prev">Previous post: <a href="<?php echo make_href_root_relative(get_permalink($previous_post)); ?>"><?php echo get_the_title($previous_post); ?></a></li> | |
| <?php endif; ?> | |
| <?php if ($next_post): // if there are newer articles ?> | |
| <li class="next">Next post: <a href="<?php echo make_href_root_relative(get_permalink($next_post)); ?>"><?php echo get_the_title($next_post); ?></a></li> | |
| <?php endif; ?> | |
| </ul> | |
| //Use Normal Pagination | |
| <?php previous_post_link('%link', '« Previous post', TRUE); ?> | |
| <?php next_post_link('%link', 'Next post »', TRUE); ?> | |
| //Use permalink | |
| <a href="<?php echo get_permalink( get_adjacent_post(false,'',true)->ID ); ?>">« Previous Post</a> | |
| <a href="<?php echo get_permalink( get_adjacent_post(false,'',false)->ID ); ?>">Next Post »</a> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment