Pagination on a Wordpress Custom Theme

Viewed 20

i have a problem with my pagination, it doesn't seem to work when i click on page 3 or 4, when it clearly says i have 4 pages when i do $the_query->max_num_pages. I dont understand what the problem is. This is my code:

$big = 999999999; // need an unlikely integer
$translated = __( 'Page', 'mytextdomain' ); // Supply translatable string
var_dump($the_query->max_num_pages);
echo paginate_links( array(
    'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ),
    'format' => '?paged=%#%',
    'current' => max( 1, get_query_var('paged') ),
    'total' => floor($the_query->max_num_pages),
    'before_page_number' => '<span class="screen-reader-text">'.$translated.' </span>'
) );
$paged = ( get_query_var('paged') ) ? get_query_var('paged') : 1;
   
    // The Query
    
    $the_query = new WP_Query([
        $atts,
        'posts_per_page' => 6,
        'post__not_in'=> get_option('sticky_post'),
        'ignore_sticky_posts' => 1,
        'paged' => $paged,
        
    ]);
0 Answers
Related