post - Wordpress nextpage display Previous 2 of 10 Next -
i'm using wp_link_pages()
split post multiple pages. want achieve shown in image below. instead of showing page numbers links, want show format (current page of total page). please me exact codes. thank in advance.
ps: don't want use plugins.
there simple solution problem. i've got inspiration source file function wp_link_pages defined.
function page_pagination( $echo = 1 ) { global $page, $numpages, $multipage, $more; if( $multipage ) { //probably should add && $more condition. $next_text = "next"; $prev_text = "prev"; if( $page < $numpages ) { $next = _wp_link_page( $i = $page + 1 ); $next_link = $next . $next_text . "</a>"; } if( $i = ( $page - 1 ) ) { $prev = _wp_link_page( $i ); $prev_link = $prev . $prev_text . "</a>"; } $output = "<div class=\"prev-next-page\">" . $prev_link . "<span class=\"page-counter\">{$page} of {$numpages}</span>" . $next_link . "</div>"; } if( $echo ){ echo $output; } return $output; }
if need more freedom can adapt function suit purposes. include function wordpress loop! example:
if ( have_posts( ) ) { while ( have_posts( ) ) { the_post( ); //rest of code the_content(); page_pagination(); } }
as can see, there "private" function _wp_link_page used solve problem. don't using "private" functions, solves our problem.
Comments
Post a Comment