Cant seem to return to the index page with the Previous link using paginate_links(). Previous link is linking to paged 2.
$paged = ( get_query_var( 'paged' ) ) ? absint( get_query_var( 'paged' ) ) : 1;
$_args = array(
'orderby' => 'post_date',
'order' => 'DSC',
'paged' => $paged,
'post_type' => 'post',
'posts_per_page' => 2, // I have more but just show to pagination
'post_status' => 'publish'
);
$_posts = new WP_Query( $_args );
$arr = paginate_links(array(
'base' => '%_%',
'format' => '?paged=%#%',
'total' => $_posts->max_num_pages,
'current' => max( 1, get_query_var('paged') ),
'show_all' => false,
'end_size' => 1,
'mid_size' => 2,
'prev_next' => true,
'prev_text' => __('« Previous'),
'next_text' => __('Next »'),
'type' => 'array',
'add_args' => false,
'add_fragment' => '',
'before_page_number' => '',
'after_page_number' => ''
));
foreach( (array) $arr as $link ) {
var_dump( $link );
}
On ?paged=2
, the Previous link is still pointing to ?paged=2
when it should return to the index page, the page where I should see all posts or return to the previous page. What is going on, please?