Skip to content

Commit

Permalink
Use $wp_rewrite->pagination_base.
Browse files Browse the repository at this point in the history
  • Loading branch information
Jutin Tadlock committed Dec 11, 2012
1 parent 6050c1e commit 82cfd1d
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions extensions/loop-pagination.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ function loop_pagination( $args = array() ) {
/* Get the max number of pages. */
$max_num_pages = intval( $wp_query->max_num_pages );

/* Get the pagination base. */
$pagination_base = $wp_rewrite->pagination_base;

/* Set up some default arguments for the paginate_links() function. */
$defaults = array(
'base' => add_query_arg( 'paged', '%#%' ),
Expand All @@ -67,7 +70,7 @@ function loop_pagination( $args = array() ) {

/* Add the $base argument to the array if the user is using permalinks. */
if ( $wp_rewrite->using_permalinks() && !is_search() )
$defaults['base'] = user_trailingslashit( trailingslashit( get_pagenum_link() ) . 'page/%#%' );
$defaults['base'] = user_trailingslashit( trailingslashit( get_pagenum_link() ) . "{$pagination_base}/%#%" );

/* @todo Find a way to make pretty links work for search in all cases. */
/**
Expand All @@ -92,7 +95,7 @@ function loop_pagination( $args = array() ) {
$page_links = paginate_links( $args );

/* Remove 'page/1' from the entire output since it's not needed. */
$page_links = str_replace( array( '&paged=1\'', '/page/1\'', '/page/1/\'' ), '\'', $page_links );
$page_links = str_replace( array( "&paged=1'", "/{$pagination_base}/1'", "/{$pagination_base}/1/'" ), '\'', $page_links );

/* Wrap the paginated links with the $before and $after elements. */
$page_links = $args['before'] . $page_links . $args['after'];
Expand Down

0 comments on commit 82cfd1d

Please sign in to comment.