When I click on page 2, there is a 404 page.

How could i fix it ?

This is my pagination on archive.php


global $query;

$big = 999999999; // need an unlikely integer

echo paginate_links( array(
    'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ),
    'format' => '?paged=%#%',
    'current' => max( 1, get_query_var('paged') ),
    'total' => $query->max_num_pages,
    'before_page_number' => '<span class="screen-reader-text">'.$translated.' </span>'
) );

  • Are you putting a call to query_posts at the top of your archive template? – Tom J Nowell Apr 12 at 14:51

Your only real reason to try and use paginate_links() seems to be your custom 'before_page_number' argument.

Ditch your code and use the_posts_pagination(); instead, pass it only the 'before_page_number' argument in an array.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.