Kildekoden
function get_post_page_list($title = false) {
global $numpages, $pages, $page;
if ($numpages > 1) {
// Strip excerpt, if existant
$pages[0] = preg_replace(',.*\s*<!--more-->\s*,is', '', $pages[0]);
$ret = '<div class="pages">';
if (false !== $title) {
$ret .= '<div>' . __($title) . '</div>';
}
$ret .= '<ol>';
foreach ($pages as $k => $v) {
// Set page number
$p = $k+1;
// Match first line in page
preg_match(',<h[1-6]{1}>([^\r\n]+)</h[1-6]{1}>[\r\n]*,', $v, $title);
// Strip tags from page title
$title = strip_tags($title[1]);
// Set standard page title if not matched
if (empty($title)) {
$title = __('Page') . ' ' . $p;
}
// Get permalink for post
$perma = get_permalink();
// Add class "current" to current page
if ($page == $p) {
$ret .= '<li class="current">';
}
else {
$ret .= '<li>';
}
if (1 == $p) {
$ret .= "<a href=\"{$perma}\">{$title}</a></li>";
}
else {
$ret .= "<a href=\"{$perma}/{$p}\">{$title}</a></li>";
}
}
$ret .= '</ol></div>';
return $ret;
}
return '';
}