Custom page navigation for wordpress

//Code phan trang
function bi_wp_corenavi($custom_query = null, $paged = null) {
global $wp_query;
if($custom_query) $main_query = $custom_query;
else $main_query = $wp_query;
$paged = ($paged) ? $paged : get_query_var('paged');
$big = 999999999;
$total = isset($main_query->max_num_pages)?$main_query->max_num_pages:'';
if($total > 1) echo '<div class="pagenavi bi-pagenavi">';
echo paginate_links( array(
'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ),
'format' => '?paged=%#%',
'current' => max( 1, $paged ),
'total' => $total,
'mid_size' => '5', // Số trang hiển thị khi có nhiều trang trước khi hiển thị ...
'prev_text' => __('Prev','bi'),
'next_text' => __('Next','bi'),
) );
if($total > 1) echo '</div>';
}

Leave a Reply

Your email address will not be published. Required fields are marked *