WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Page-Navi (2 posts)

  1. Takeru
    Member
    Posted 8 months ago #

    I keep receiving a 404 on the last page of my website for every odd number of post I have. If I have an even number of post the last page will appear.

    website: kobayo.com

    below is an extract from my themes index.php

    <?php /* Set num of cols */ ?>
                <?php $col = 0; $numcols = 3; ?>
    
                <?php
    				/* Limit num of post displayed & set paged */
    				$feat_query = new WP_Query( array('posts_per_page' => 9, 'paged' => get_query_var('paged') ) );
    			 ?>
    
                <?php
    				/* Create array to store post ID, prevent duplicate post being displayed */
    				//$ids = array();
    			?>
    
                <?php /* Start the latest post loop */ ?>
                <?php while ( $feat_query->have_posts() ) : $feat_query->the_post(); ?>
    
    				<?php if ($ct && $ct%$numcols==0) echo '<div class="clearcol"></div>'; ?>
                    <div class="col">
                        <?php get_template_part( 'content', get_post_format() ); ?>
                    </div><!-- .col -->
                    <?php $ct++; ?>
                    <?php $ids[]= $post->ID; ?>
                <?php endwhile; ?>
    
                <!-- Add page navigation via pagenavi plugin -->
                <?php if(function_exists('wp_pagenavi')) { wp_pagenavi( array( 'query' => $feat_query ) ); } ?>
    
                <?php wp_reset_postdata(); ?>
    
                <div class="clearcol"></div>

    Thanks for you time.

  2. Takeru
    Member
    Posted 8 months ago #

    Solved! Had to change the number of post in the admin panel to equal the number of post in the query. Settings -> Reading.

Reply

You must log in to post.

About this Topic

Tags