Last active
April 20, 2017 06:24
-
-
Save sadrul/d9b47eff0a9cef3c73e0 to your computer and use it in GitHub Desktop.
Number pagination function works in bp pages
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// need to pass $the_query | |
function batd_num_pagination($the_query){ | |
$total_pages = $the_query->max_num_pages; | |
if ($total_pages > 1) { | |
$paged = batd_paged_query_var(); | |
$current_page = max(1, $paged); | |
echo '<div class="pagination no-ajax batd-pag" id="pag-top">'; | |
echo paginate_links(array( | |
'format' => '?page=%#%', // can also be used 'page/%#%' in other wp pages, not in bp pages | |
'current' => $current_page, | |
'total' => $total_pages, | |
'type' => 'plain', | |
'prev_next' => True, | |
'prev_text' => __('←', 'buddyboss-batd'), | |
'next_text' => __('→', 'buddyboss-batd'), | |
)); | |
echo '</div>'; | |
} | |
} | |
function batd_paged_query_var(){ | |
if ( get_query_var('paged') ) { $paged = get_query_var('paged'); } | |
elseif ( get_query_var('page') ) { $paged = get_query_var('page'); } | |
else { $paged = 1; } | |
return $paged; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment