I am using the paginate_links function in a custom theme to generate the pagination links which is working fine however the page 1 link which is /blog/page/1 gets a 301 redirect to /blog/.
This is the same content and page so is fine but it seems like an unnecessary redirect so I was trying to find a way to change the page 1 link to just to be /blog/.
I've had a search around and feel like something could be done in the base variable rather than putting in custom pagination but of the things I've tried it breaks the pagination.
$current = max( 1, get_query_var('paged') );
$big = 999999999;
echo paginate_links(
[
'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ),
'total' => $update->max_num_pages,
'current' => $current,
'format' => '/blog/page/%#%',
'show_all' => false,
'type' => 'plain',
'end_size' => 4,
'mid_size' => 1,
'prev_next' => true,
'prev_text' => '<i class="fas fa-arrow-left"></i>',
'next_text' => '<i class="fas fa-arrow-right"></i>',
'add_args' => false,
'add_fragment' => '',
]
);
/blog
not going to show the first page anyway? Pagination starts at 1 not 0, the first page is 1, the second page is 2, etc, there is no "not on a page" state, so loading/blog
would give you exactly the same content as/blog/page/1
, so it redirects to prevent duplication – Tom J Nowell♦ Jan 9 '20 at 16:14