Created
December 8, 2012 03:19
-
-
Save figureone/4238427 to your computer and use it in GitHub Desktop.
WordPress: print link to next page
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
<?php | |
$allPages = get_pages(array( | |
'sort_column' => 'menu_order', | |
'sort_order' => 'asc', | |
)); | |
for ($i=0; $i<count($allPages); $i++) // advance iterator to current page | |
if ($allPages[$i]->ID == $post->ID) | |
break; | |
$nextURI = $i<count($allPages)-1 ? get_permalink($allPages[$i+1]->ID) : ""; | |
$nextTitle = strlen($nextURI)>0 ? $allPages[$i+1]->post_title : ""; | |
?> | |
<a href="<?php print $nextURI; ?>"><?php print $nextTitle; ?></a> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment