Quantcast
Channel: WordPress.org Forums » All Topics
Viewing all articles
Browse latest Browse all 59525

PageNavi plugin and custom post display – gives /page/2/ not found

$
0
0

Replies: 0

Fact: My blog home page has a custom query.

Fact: I installed pagenavi plugin to add pagination to my blog home page, but when I tried to click on the pagenavi controls to get to the second page of the blog, I get the index.php returned with a “Page not found – No content is appearing for this page” message, even though there are more blogs to be displayed.

Fact: I know this has been discussed a lot.. and I’ve read and tried many suggestions.. just no joy for me.. so I am hoping someone can help me.

Here is the code that gets my blog posts for my Posts Page (this code is on home.php, because front-page.php is used for my static Front Page).

		<?php
			$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
			$myquery = new WP_Query(
				array(
					'post_type' => 'post',
					'post_status' => 'publish',
					'order'=> 'DESC', 
					'orderby' => 'post_date', 
					'category_name' => 'Recipes',
					'posts_per_page' => 1,
					'paged' => $paged,
					// add any other parameters to your wp_query array
				)   
			);  
			?>

		<?php
		if ($myquery->have_posts()) :  while ($myquery->have_posts()) : $myquery->the_post();
		?>

		<!-- Start your post -->

				<div class="col-lg-4 col-md-4 col-sm-6 col-xs-12 home-blog-list" style="float: left; display:block">				
					<center><div class="img-responsive box-shadow shadow-effect" style=""><a href="<?php the_permalink(); ?>"><?php the_post_thumbnail(); ?></a></div>
					<h3 class="entry-title script" style="text-align: center;"><a class="entry-title-link" href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3><center>
				</div>

		<!-- End of your post -->

		<?php endwhile; ?>
		<?php wp_pagenavi( array( 'query' => $myquery ) ); ?><!-- IMPORTANT: make sure to include an array with your previously declared query values in here -->
		<?php wp_reset_query(); ?>
		<?php else : ?>
		<p>No posts found</p>
		<?php endif; ?>	

This all works fine as far as displaying the posts. This version of code I am using has some code that was suggested to help the issue (of ‘page not found’ with pagenavi pagination), but I still have the problem. (Also note, I am developing the site, and only have 3 blogs created so far, so in order to test pagination, I set my code to just display one post per page, so I can get 3 pages to test.)

My settings/readings is set to- “Blog pages show at most: 9”. (I heard that could be a problem also. (And yes, I have saved the page to reset the permalinks).

I have also tried adding this code to the function.php page as I read it could fix the problem:

function my_pagination_rewrite() {
    add_rewrite_rule('blog/page/?([0-9]{1,})/?$', 'index.php?category_name=blog&paged=$matches[1]', 'top');
}
add_action('init', 'my_pagination_rewrite');

Even with all these changes to supposedly fix my problem, I still can’t get to page 2 on the pagenavi navigation links. Although my blog’s home page still displays great, so I haven’t broken the display… yet!

Can anyone see what the problem is?

Thanks,
SunnyOz


Viewing all articles
Browse latest Browse all 59525

Trending Articles