After
Next the ‘Next’ and ‘Last’ page links are defined, depending on whether or not the current page is the last page. This is basically an inversion of how the ‘First’ and ‘Prev’ links are defined above. Note that the first element added to the ‘after’ array element is the separator, because the standard numeric pagination display does not include one after the last link.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | if ( $page < $numpages ) { $args[ ‘after’ ] .= $args[ ‘separator’ ]; $args[ ‘after’ ] .= _wp_link_page( $page + 1 ) . $args[ ‘nextpagelink’ ] . ‘</a>’; $args[ ‘after’ ] .= $args[ ‘separator’ ]; $args[ ‘after’ ] .= _wp_link_page( $numpages ) . $args[ ‘lastpagelink’ ] . ‘</a>’; } else { $args[ ‘after’ ] .= $args[ ‘separator’ ]; $args[ ‘after’ ] .= $args[ ‘nextpagelink’ ]; $args[ ‘after’ ] .= $args[ ‘separator’ ]; $args[ ‘after’ ] .= $args[ ‘lastpagelink’ ]; } |
‘lastpagelink’ is not part of the standard definition and is only defined locally.
Next the command to view all the pages as one complete page is added.
1 2 | $args[ ‘after’ ] .= ‘<br/>’; $args[ ‘after’ ] .= ‘<a href=“ ‘ . get_pagenum_link( 1 ) . ( preg_match( ‘/\?/’, get_pagenum_link( 1 ) ) ? ‘&’ : ‘?’ ) . ‘viewall=true’ . ’ ”>’ . $args[ ‘viewalllink’ ] . ‘</a>’; |
The get_pagenum_link()
function is called to get the URL of the base page. The preg_match()
function checks to use the correct separator depending on whether there are already parameters or if this is the only parameter.
‘viewalllink’ is not part of the standard definition and is only defined locally.
Finally the beginning <p>
and <div>
elements are closed to finish the display.
1 2 | $args[ ‘after’ ] .= ‘</p>’; $args[ ‘after’ ] .= ‘</div>’; |
The finished ‘args’ array is then returned to the wp_link_pages
function and used to create the final pagination navigation display.
Personal Links
My Amazon Wishlist
My DeviantArt Gallery
My Facebook Page
My Goodreads Bookshelf
My Smashwords Catalog
My Twitter Feed
My WordPress Profile