Skip to content

Instantly share code, notes, and snippets.

@sadrul
Last active April 20, 2017 06:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sadrul/d9b47eff0a9cef3c73e0 to your computer and use it in GitHub Desktop.
Save sadrul/d9b47eff0a9cef3c73e0 to your computer and use it in GitHub Desktop.
Number pagination function works in bp pages
<?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' => __('&larr;', 'buddyboss-batd'),
'next_text' => __('&rarr;', '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