ap_pagination( float $current = false, int $total = false, string $format = '?paged=%#%', string $page_num_link = false )
Description #
Anspress pagination Uses paginate_links.
Parameters #
- $currentfloat (Optional) Current paged, if not set then get_query_var('paged') is used. Default value: false
- $totalint (Optional) Total number of pages, if not set then global $questions is used. Default value: false
- $formatstring (Optional) pagination format. Default value: '?paged=%#%'
- $page_num_linkstring (Optional) Base link. Default value: false
Source #
File: includes/theme.php
function ap_pagination( $current = false, $total = false, $format = '?paged=%#%', $page_num_link = false ) { global $ap_max_num_pages, $ap_current; if ( is_front_page() ) { $format = ''; } $big = 999999999; // Need an unlikely integer. if ( false === $current ) { $paged = ap_sanitize_unslash( 'ap_paged', 'r', 1 ); $current = is_front_page() ? max( 1, $paged ) : max( 1, get_query_var( 'paged' ) ); } elseif ( ! empty( $ap_current ) ) { $current = $ap_current; } if ( ! empty( $ap_max_num_pages ) ) { $total = $ap_max_num_pages; } elseif ( false === $total && isset( anspress()->questions->max_num_pages ) ) { $total = anspress()->questions->max_num_pages; } if ( false === $page_num_link ) { $page_num_link = str_replace( array( '&', '&' ), '&', get_pagenum_link( $big ) ); } $base = str_replace( $big, '%#%', $page_num_link ); if ( 1 === $total ) { return; } echo '<div class="ap-pagination clearfix">'; $links = paginate_links( array( 'base' => $base, 'format' => $format, 'current' => $current, 'total' => $total, 'end_size' => 2, 'mid_size' => 2, ) ); if ( $links ) { $links = str_replace( '<a class="next page-numbers"', '<a class="next page-numbers" rel="next"', $links ); $links = str_replace( '<a class="prev page-numbers"', '<a class="prev page-numbers" rel="prev"', $links ); echo wp_kses_post( $links ); } echo '</div>'; }
Expand full source code Collapse full source code View on GitHub: includes/theme.php:134
Add your comment