Pagination Links showing incorrect previous page number

You are using the code from the example in the Codex, but this is for the default “plain” permalinks for the default blog homepage. My guess is that you are doing this for an archive rather than the homepage.

Search & Archive pages

By default, paginate_links assumes the pagination is for the blog on the homepage. In all other cases, you need to change the code as follows (Ref: Codex: paginate_links):

$big = 999999999; // need an unlikely integer

echo paginate_links( array(
    'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ),
    'format' => '?paged=%#%',

    // rest of your arguments here

) );

What this does:

We need to change paginate_links to make it use the link for the archive page instead of the homepage. We do this by changing the base argument to include the url. We also need to change the format to use the correct parameter.

  1. Create a variable with a huge number that’s unlikely to ever be a valid page number, e.g.
    $big = 999999999;

  2. set up your base argument

For base, you need to tell paginate_links to use the url. We do this by using get_pagenum_link to get the url for a page that will never exist, and then we replace the page number in the url with the actual page number

'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) )
  1. set up your format argument

format defaults to use the page parameter (for the static homepage) so we need to change it to use paged instead:

    'format' => '?paged=%#%',

NOTE: Pretty Permalinks

If you are displaying the pagination on the homepage and using pretty permalinks, but are still having issues, try the following.

According to the Codex, if you are using “pretty” permalinks, you should change the format as follows:

'format'             => '/page/%#%',

format

(string) (optional) Used for Pagination structure. The default value is ?page=%#%, If using pretty permalinks this would be /page/%#%, where the %#% is replaced by the page number.

This is good practice, but its not required because WordPress rewrite rules will automatically translate the ?paged parameter