$url_parts =
explode( '?',
$pagenum_link );
// Get max pages and current page out of the current query, if available.
$total =
isset( $wp_query->max_num_pages
) ?
$wp_query->max_num_pages : 1;
$current =
get_query_var( 'paged'
) ?
(int) get_query_var( 'paged'
) : 1;
// Append the format placeholder to the base URL.
$pagenum_link =
trailingslashit( $url_parts[0
] ) . '%_%';
// URL base depends on permalink settings.
$format =
$wp_rewrite->
using_index_permalinks() && !
strpos( $pagenum_link, 'index.php'
) ? 'index.php/' : '';
$format .=
$wp_rewrite->
using_permalinks() ?
user_trailingslashit( $wp_rewrite->pagination_base . '/%#%', 'paged'
) : '?paged=%#%';
$defaults = array
( 'base' =>
$pagenum_link, // http://example.com/all_posts.php%_% : %_% is replaced by format (below).
'format' =>
$format, // ?page=%#% : %#% is replaced by the page number.
'total' =>
$total,
'current' =>
$current,
'aria_current' => 'page',
'show_all' => false,
'prev_next' => true,
'prev_text' =>
__( '« Previous'
),
'next_text' =>
__( 'Next »'
),