'nav-above', 'train' => true, 'train_size' => 2, 'train_align' => 'mc', ); $args = (object)wp_parse_args( $args, $defaults ); // Early exit - Do not generate empty markup in archives if there's only one page. global $wp_query; if ( $wp_query->max_num_pages < 2 ) return ''; // Setup the bar. ob_start(); if ( $wp_query->max_num_pages > 1 ) { // The Developer requested a train of archive page numbers. if ( $args->train ) { $big = 999999999; // need an unlikely integer $paginate_args = array( 'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ), 'format' => '?paged=%#%', 'current' => max( 1, get_query_var( 'paged' ) ), 'total' => $wp_query->max_num_pages, 'type' => 'array', 'prev_next' => true, 'prev_text' => ' '.__( 'Previous', 'bpq' ), 'next_text' => __( 'Next', 'bpq' ).' ', 'mid_size' => $args->train_size, 'end_size' => 1 ); $links = paginate_links( $paginate_args ); echo '
'; echo ''; echo '
'; } // Or the Developer just requested a simple next/prev button combination. else { echo ''; } } // Return the markup. return ob_get_clean(); } /** * With respect to the main WP loop, this function generates prev/next links * specifically when looking at an attachment page. * * @link http://themeshaper.com/2012/11/02/the-wordpress-theme-single-post-post-attachment-404-templates/ * @param array $args Can be any of the following arguments: * string $id The id to give the bar - typically 'nav-above' or 'nav-below' * @return type The desired markup */ function tag_pagination_attachment( $args = array() ) { // Merge default arguments and the arguments supplied by the caller. $defaults = array( 'id' => 'nav-above', ); $args = (object)wp_parse_args( $args, $defaults ); // Setup the bar. ob_start(); echo ''; // Return the markup. return ob_get_clean(); } /** * With respect to single pages/posts, this function generates * prev/next links to cycle through comments. * * @link http://themeshaper.com/2012/11/04/the-wordpress-theme-comments-template/ * @param array $args Can be any of the following arguments: * string $id The id to give the bar - typically 'nav-above' or 'nav-below' * @return type The desired markup */ function tag_pagination_comments( $args = array() ) { // Merge default arguments and the arguments supplied by the caller. $defaults = array( 'id' => 'comment-nav-above', ); $args = (object)wp_parse_args( $args, $defaults ); // Early exit - Are there comments to navigate through? if ( !( get_comment_pages_count() > 1 && get_option( 'page_comments' ) ) ) return ''; // Setup the bar. ob_start(); echo ''; // Return the markup. return ob_get_clean(); } /** * Provides a pagination control for a specific post * that uses the quicktags. * * @link http://codex.wordpress.org/Function_Reference/wp_link_pages * @param array $args Can be any of the following arguments: * TBD * @return string The desired text */ function tag_pagination_nextpage( $args = array() ) { // Merge default arguments and the arguments supplied by the caller. $defaults = array( // TBD ); $args = (object)wp_parse_args( $args, $defaults ); // Call WP for the pagination controls. $link_args = array( 'before' => '', 'link_before' => ' '.__( 'Page ', 'bpq' ), 'link_after' => '', 'separator' => ' ', 'next_or_number' => 'number', 'echo' => 0 ); $markup = wp_link_pages( $link_args ); //DAN-HACK: Start // // There is no parameter to send to wp_link_pages that can surround the links - // so, wrap the links, using a string replace, with
  • elements. // // Note: We pass '' into wp_link_pages to give us something to find // on the current page (which normally has no markup decoration). $markup = str_replace( '', '
  • ', $markup ); $markup = str_replace( ' ', '
  • ', $markup ); $markup = str_replace( ' ', '
  • ', $markup ); // //DAN-HACK: End // Ask the client if they want to change this up a bit (or ignore it completely). return apply_filters( 'filter_bpq_post_nextpage_pagination', $markup ); } /** * With respect to the main WP loop, this function generates prev/next links * for use on single pages/posts. * * @link http://themeshaper.com/2012/11/01/the-wordpress-theme-index-template/ * @param array $args Can be any of the following arguments: * string $id The id to give the bar - typically 'nav-above' or 'nav-below' * @return type The desired markup */ function tag_pagination_single( $args = array() ) { // Merge default arguments and the arguments supplied by the caller. $defaults = array( 'id' => 'nav-above', ); $args = (object)wp_parse_args( $args, $defaults ); // Early exit - Do not generate empty markup on single pages if there is nowhere to navigate. if ( !get_adjacent_post( false, '', false ) && !get_adjacent_post( false, '', true ) ) return ''; // Setup the bar. ob_start(); echo ''; // Return the markup. return ob_get_clean(); } ?>