Current File : /home/kelaby89/sergio-cuchi.tattoo/wp-content/themes/maori/includes/bs4pagination.php |
<?php
/*---------------------------------------------------
Bootstrap Pagination
----------------------------------------------------*/
if ( ! function_exists( 'maori_pagination' ) ) {
function maori_pagination() {
global $wp_query;
$pages = paginate_links( [
'base' => str_replace( 999999999, '%#%', esc_url( get_pagenum_link( 999999999 ) ) ),
'format' => '?paged=%#%',
'current' => max( 1, get_query_var( 'paged' ) ),
'total' => $wp_query->max_num_pages,
'type' => 'array',
'show_all' => false,
'end_size' => 3,
'mid_size' => 1,
'prev_next' => true,
'prev_text' => '<i class="fa fa-chevron-left"></i>',
'next_text' => '<i class="fa fa-chevron-right"></i>',
'add_args' => false,
'add_fragment' => ''
]
);
if ( is_array( $pages ) ) {
$pagination = '<ul class="pagination flex-wrap">';
foreach ($pages as $page) {
$pagination .= '<li class="page-item' . (strpos($page, 'current') !== false ? ' active' : '') . '"> ' . str_replace('page-numbers', 'page-link', $page) . '</li>';
}
$pagination .= '</ul>';
echo wp_kses_post($pagination);
}
return null;
}
}
/*---------------------------------------------------
Bootstrap Pagination for Custom Queries
----------------------------------------------------*/
if ( ! function_exists( 'maori_custom_pagination' ) ) {
function maori_custom_pagination($maori_custom_query) {
if ( get_query_var( 'paged' ) ) { $paged = get_query_var( 'paged' ); }
elseif ( get_query_var( 'page' ) ) { $paged = get_query_var( 'page' ); }
else { $paged = 1; }
$pages = paginate_links( [
'base' => str_replace( 999999999, '%#%', esc_url( get_pagenum_link( 999999999 ) ) ),
'format' => '?paged=%#%',
'current' => max( 1, $paged ),
'total' => $maori_custom_query->max_num_pages,
'type' => 'array',
'show_all' => false,
'end_size' => 3,
'mid_size' => 1,
'prev_next' => true,
'prev_text' => '<i class="fa fa-chevron-left"></i>',
'next_text' => '<i class="fa fa-chevron-right"></i>',
'add_args' => false,
'add_fragment' => ''
]
);
if ( is_array( $pages ) ) {
$pagination = '<ul class="pagination flex-wrap">';
foreach ($pages as $page) {
$pagination .= '<li class="page-item' . (strpos($page, 'current') !== false ? ' active' : '') . '"> ' . str_replace('page-numbers', 'page-link', $page) . '</li>';
}
$pagination .= '</ul>';
echo wp_kses_post($pagination);
}
return null;
}
}
?>