pagination
function pagination_ajax($total_pages = 0, $current = 1, $type = ''){
global $[WP_Query](http://codex.wordpress.org/Class_Reference/WP_Query);
$big = 999999999; // need an unlikely integer
if($total_pages === 0) $total_pages = $[WP_Query](http://codex.wordpress.org/Class_Reference/WP_Query)->max_num_pages;
if ( [get_query_var](http://codex.wordpress.org/Function_Reference/get_query_var)( 'paged' ) ) { $paged = [get_query_var](http://codex.wordpress.org/Function_Reference/get_query_var)( 'paged' ); }
elseif ( [get_query_var](http://codex.wordpress.org/Function_Reference/get_query_var)( 'page' ) ) { $paged = [get_query_var](http://codex.wordpress.org/Function_Reference/get_query_var)( 'page' ); }
elseif( $current > 1 ) { $paged = $current; }
else { $paged = 1; }
$html = '
<div class="ajax-pagination" data-ajax="'.$type.'">' .
[paginate_links](http://codex.wordpress.org/Function_Reference/paginate_links)( array(
'base' => str_replace( $big, '%#%', [esc_url](http://codex.wordpress.org/Function_Reference/esc_url)( get_pagenum_link( $big ) ) ),
//'format' => '?page=%#%',
'current' => max( 1, $paged ),
'total' => $total_pages
) )
.
'</div>';
return $html;
}