最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

404 error - Please Help me with Archive 404 Pagination

matteradmin4PV0评论

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

How could i fix it ?

This is my pagination on archive.php

<?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>'
) );

?>

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

How could i fix it ?

This is my pagination on archive.php

<?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>'
) );

?>
Share Improve this question edited Apr 12, 2019 at 15:46 fuxia 107k39 gold badges255 silver badges459 bronze badges asked Apr 12, 2019 at 14:30 WDCreativWDCreativ 32 silver badges6 bronze badges 1
  • Are you putting a call to query_posts at the top of your archive template? – Tom J Nowell Commented Apr 12, 2019 at 14:51
Add a comment  | 

1 Answer 1

Reset to default 0

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.

Post a comment

comment list (0)

  1. No comments so far