Custom Titles to Replace Page Numbers on Post Pagination
-
Hello all,
I got this nifty function from wordpress.stackexchange.com https://wordpress.stackexchange.com/a/11588/16083
What it does is display a custom post title instead of just the number on a paginated post.
Help >> I would like it to only show the next page as opposed to all pages. So when on page one, it shows a link to page two only and on page two, a link to page three and so on..
function wp_link_pages_titled($args = '') { $defaults = array( 'before' => '<p>' . __('Pages:'), 'after' => '</p>', 'link_before' => '', 'link_after' => '', 'echo' => 1 ); $r = wp_parse_args( $args, $defaults ); extract( $r, EXTR_SKIP ); global $page, $numpages, $multipage, $more, $pagenow, $pages; $output = ''; if ( $multipage ) { $output .= $before; for ( $i = 1; $i < ($numpages+1); $i = $i + 1 ) { $part_content = $pages[$i-1]; $has_part_title = strpos( $part_content, '<!--pagetitle:' ); if( 0 === $has_part_title ) { $end = strpos( $part_content, '-->' ); $title = trim( str_replace( '<!--pagetitle:', '', substr( $part_content, 0, $end ) ) ); } $output .= ' '; if ( ($i != $page) || ((!$more) && ($page==1)) ) { $output .= _wp_link_page($i); } $title = isset( $title ) && ( strlen( $title ) > 0 ) ? $title : 'First'; $output .= $link_before . $title . $link_after; if ( ($i != $page) || ((!$more) && ($page==1)) ) $output .= '</a>'; } $output .= $after; } if ( $echo ) echo $output; return $output; }
Thanks
- The topic ‘Custom Titles to Replace Page Numbers on Post Pagination’ is closed to new replies.