I am using the following code for my pagination.
// Pagination
function my_paginate_links() {
global $wp_rewrite, $wp_query;
$wp_query->query_vars['paged'] > 1 ? $current = $wp_query->query_vars['paged'] : $current = 1;
$pagination = array(
'base' => @add_query_arg('page','%#%'),
'format' => '',
'total' => $wp_query->max_num_pages,
'current' => $current,
'prev_text' => __(''),
'next_text' => __('next »'),
'end_size' => 1,
'mid_size' => 2,
'show_all' => true,
'type' => 'list'
);
if ( $wp_rewrite->using_permalinks() )
$pagination['base'] = user_trailingslashit( trailingslashit( remove_query_arg( 's', get_pagenum_link( 1 ) ) ) . 'page/%#%/', 'paged' );
if ( !empty( $wp_query->query_vars['s'] ) )
$pagination['add_args'] = array( 's' => get_query_var( 's' ) );
echo paginate_links( $pagination );
}
When it’s on the first page, the ‘previous’ link doesn’t show. I understand why but I’d like it to show because I am designing the site a certain way. Is there a part of the code above I can change to make this happen? I have read through the codex regarding this but couldn’t find an answer that made sense to me. I’d appreciate any guidance. Thank you.
Looking at the source of
paginate_links()
it seems there is no option available to always include a previous or next link. The function simply compares the current page number with the total page number to determine whether these links need to be added.Working around this problem is possible, though. This should get you started:
A little bit late, but I just had this problem and found your unsolved issue. Here’s what I came to… We can get an array of link, so, if we compare the page number we are on, we can manually add our prev/next link and loop the rest of the links: