For the header
First of all you have to know how retrieve the current page, that is done by
get_query_var('page')
Knowing it, writing what you want is easy. It can be a little hard if you want to link the previous page correctly. In this case you have to use an internal function of wordpress, _wp_link_page
:
$now = get_query_var('page');
if ( $now > 1 ) {
$prev = $now-1;
$anchor = sprintf( __('Continued from page %d'), $prev );
$prev_link = _wp_link_page( $prev ) . $anchor . '</a>';
echo '<p>' . apply_filters( 'wp_link_pages_link', $prev_link, $prev ) . '</p>';
}
For the footer
If you see at Codex for wp_link_pages
you understand that the behavior of this function is usually showing page number or showing next and previous link, not both as you want.
For me, solution is create a customized version of the function, putting next code in the functions.php
:
function wp_link_pages_customized() {
global $page, $numpages, $multipage;
if ( $multipage ) {
$output="";
$prev = ( $page < 2 ) ? false : _wp_link_page( $page-1 ) . __('« Previous page ') . '</a>';
$next = ( $page == $numpages ) ? false : _wp_link_page( $page+1 ) . __('Next page »') . '</a>';
for ( $i = 1; $i <= $numpages; $i++ ) {
if ( $i != $page ) {
$output .= _wp_link_page( $i ) . $i . '</a> | ';
} else {
$output .= $i . ' | ';
}
}
if ( $prev ) $output = $prev . ' | ' . $output;
$output = ( $next ) ? $output . $next : rtrim($output, '| ');
echo $output;
}
}
and then, in the footer template, simply use like so:
<p><?php wp_link_pages_customized(); ?></p>