Last active
August 29, 2015 14:13
-
-
Save tahirtaous/d67522c42f36a084843f to your computer and use it in GitHub Desktop.
WordPress Next & Prevous Page not Post with Bootstrap pager styling
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
<!-- add this code in page.php to display Next page and Previous page link below pages in WordPress | |
this will display next and previous page link not next previous post link | |
http://codex.wordpress.org/Next_and_Previous_Links#The_Next_and_Previous_Pages --> | |
<?php | |
$pagelist = get_pages('sort_column=menu_order&sort_order=asc'); | |
$pages = array(); | |
foreach ($pagelist as $page) { | |
$pages[] += $page->ID; | |
} | |
$current = array_search(get_the_ID(), $pages); | |
$prevID = $pages[$current-1]; | |
$nextID = $pages[$current+1]; | |
?> | |
<ul class="pager"> | |
<?php if (!empty($prevID)) { ?> | |
<li class="previous"> | |
<a href="<?php echo get_permalink($prevID); ?>" | |
title="<?php echo get_the_title($prevID); ?>">Previous Page</a> | |
</li> | |
<?php } | |
if (!empty($nextID)) { ?> | |
<li class="next"> | |
<a href="<?php echo get_permalink($nextID); ?>" | |
title="<?php echo get_the_title($nextID); ?>">Next Page</a> | |
</li> | |
<?php } ?> | |
</ul><!-- .navigation --> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If you want to display title of next and previous instead of PREVIOUS PAGE and NEXT PAGE use this code