/ Published in: PHP
![](/img/icon_sav.png?v3)
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
<?php /* prev/next links */ if ($post->post_parent == 19) { /* 19 == id of 'Rooms' page */ $toplevel = 'title_li=&depth=1&echo=0&exclude='.$exclude; $siblings = $toplevel.'&child_of='.$post->post_parent; pause_exclude_pages(); $links = ($post->post_parent) ? wp_list_pages($siblings) : wp_list_pages($toplevel); resume_exclude_pages(); } else { $links = ($post->post_parent) ? wp_list_pages($siblings) : wp_list_pages($toplevel); } foreach($links as $k=>$v) { if (strpos($v,'current_page_item') !== FALSE) { $current = $k; } $links[$k] = $v.'</li>';} if ($current == $total) $next = '0'; // if you're on the last page, next will be the first if ($current == '0') $prev = $total; // if you're on the first page, prev will be the last function change_anchor_text($link, $newtext, $placement) { if($placement == 'before') { } else if ($placement == 'after') { } else if ($placement == 'replace') { } } $prevLinkb = $prevLink; $prevLink = change_anchor_text($prevLink, ' < View Previous Room ', 'replace'); /* link customization goes here */ $nextLink = change_anchor_text($nextLink, ' View Next Room > ', 'replace'); $prepend = ''; $separator = '<a href="/lodging/" class="norm">Return to All Rooms</a>'; $separator2 = '<a href="#" class="norm">Check Availability Online</a>'; echo '<p class="pnpn">'.$prepend.$prevLink.$separator.$nextLink.'</p>'; } /* end prev/next links */ ?>
URL: http://trepmal.com/scripts/previousnext-links-for-pages-in-wordpress/
Comments
![RSS Feed for Comments RSS Icon](/images/rss.png?v3)