Getting and Customising Pagination:
function getPagination() {
global $wp_query;
$a = paginate_links(array(
'current' => max(1, get_query_var('paged')),
'total' => $wp_query->max_num_pages,
'type' => 'array',
'aria_current' => false,
'show_all' => true,
'end_size' => 2,
'mid_size' => 2,
'prev_next' => true,
'prev_text' => '<div class="pg_arrow left"></div>',
'next_text' => '<div class="pg_arrow right"></div>',
));
if (empty($a)) return false;
foreach($a as &$l) {
$l = str_replace('prev page-numbers', 'pg_item', $l);
$l = str_replace('next page-numbers', 'pg_item', $l);
$l = str_replace('page-numbers', 'pg_item pg_num', $l);
$l = str_replace(' aria-current=""', '', $l);
$l = str_replace('span', 'a', $l);
$l = str_replace('current', 'active', $l);
}
return $a;
}
Calling:
if spaces are needed in front
foreach(getPagination() as $p) {
echo " " . $p . "\n";
}
no spaces
echo implode("\n", getPagination());