Skip to content

Commit

Permalink
Better pagination generation when using pretty permalinks.
Browse files Browse the repository at this point in the history
See #438.
  • Loading branch information
boonebgorges committed Mar 6, 2015
1 parent 1c02b32 commit 99cb2de
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions includes/templatetags.php
Original file line number Diff line number Diff line change
Expand Up @@ -1063,7 +1063,7 @@ function bp_docs_get_delete_doc_button( $doc_id = false ) {
* @since 1.0-beta-2
*/
function bp_docs_paginate_links() {
global $bp, $wp_query;
global $bp, $wp_query, $wp_rewrite;

$cur_page = 1;
if ( isset( $_GET['paged'] ) ) {
Expand All @@ -1074,14 +1074,20 @@ function bp_docs_paginate_links() {

$page_links_total = $bp->bp_docs->doc_query->max_num_pages;

$page_links = paginate_links( array(
$pagination_args = array(
'base' => add_query_arg( 'paged', '%#%' ),
'format' => '',
'prev_text' => __('«'),
'next_text' => __('»'),
'total' => $page_links_total,
'current' => $cur_page
));
'current' => $cur_page,
);

if ( $wp_rewrite->using_permalinks() ) {
$pagination_args['base'] = user_trailingslashit( trailingslashit( bp_docs_get_archive_link() ) . $wp_rewrite->pagination_base . '/%#%/', 'bp-docs-directory' );
}

$page_links = paginate_links( $pagination_args );

echo apply_filters( 'bp_docs_paginate_links', $page_links );
}
Expand Down

0 comments on commit 99cb2de

Please sign in to comment.