Support » Plugin: WP-PageNavi » Page 13+ returns 404 when WP-PageNavi used with WP_Query

  • I have several custom post types(CPTs), and in a cpt archive page, I use WP_Query to get posts from those CPTs.
    It works fine and it has 164 posts found, posts_per_page is set to 12, max_num_pages is 14.
    However, page 13 and 14 returns 404.

    Here, I change posts_per_page to 16, that makes max_num_pages to 11.
    Page 11 shows fine with the last 4 posts.

    So, number of posts is fine and fetched ok. Why page 13 and up get 404?

    I have already find workaround to use pre_get_posts, and works perfect.
    But I want to know why this happened.

Viewing 1 replies (of 1 total)
  • The same issue here. This is my code:

    <form role="search" id="searchform-top" method="get" action="<?php bloginfo('url'); ?>"> <?php wp_dropdown_categories('show_option_none=Select Category&exclude=1,3,4,5'); ?> <input type="text" name="s" id="s" size="15" /> <input type="submit" value="Search" /></form><h2 class="title">Search results for: "<?php echo esc_html(wp_unslash($_GET['s'])); ?>"</h2>
    
    <?php global $query_string; query_posts( $query_string . '&order=DSC&posts_per_page=9' ); if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
    <a href="<?php the_permalink() ?>" rel="bookmark">
    
    <?php if (has_post_thumbnail()){echo'<div class="back-image">';the_post_thumbnail('medium'); echo'</div>';} ?>
    
    <?php if ( !in_category('42') ) { ?>
    <h1><?php the_title(); ?></h1><?php } ?>
    <?php if(has_excerpt($post->ID)) {echo wp_trim_words( get_the_excerpt(), 22, ' ...' );} else {echo wp_trim_words( get_the_content(), 22, ' ...' );} ?>
    <?php the_time('d/m/Y'); ?
    <?php $category = get_the_category(); echo $category[0]->cat_name;?>
    </a>			
    <?php endwhile; ?>
    
    <?php if(function_exists('wp_pagenavi')) : wp_pagenavi(); ?>
Viewing 1 replies (of 1 total)
  • You must be logged in to reply to this topic.