Symptoms
Visiting /blog/ loads the first 10 posts, as expected.
Visiting /blog/page/2/ (and onward) loads the new URL but with the same 10 posts. Nothing changes but the URL.
Setup Details
Custom Permalink Structure: /blog/%year%/%monthnum%/%day%/%postname%/
Static Posts Page: “Blog” (slug of ‘blog’)
I’m using home.php
to displays posts with the following markup:
<?php
/**
* The archive for blog posts
*/
get_header(); ?>
<div id="main-content">
<div class="container">
<section id="content" class="blog">
<?php while ( have_posts() ) : the_post(); ?>
<?php get_template_part( 'content', 'blog-index' ); ?>
<?php endwhile; ?>
</section>
<?php get_sidebar( 'blog' ); ?>
<div class="pagination">
<?php wp_pagenavi(); ?>
</div>
</div>
</div>
<?php get_footer(); ?>
I’ve checked for plugin conflicts and I am running a relatively minimalistic setup. I’m using WP-PageNavi to generate the pagination.
I’ve also tried renaming the /blog/ page to ‘blog2’ with the thought that there might be a permalink conflict – same result. /blog2/page/2/ loads the same first 10 posts.
Any ideas what might be the cause here?
try this code and also increase the size of show posts in SETTINGS->Reading->Blog pages show at most 10 to 50 or 100, hope so it will help you.
Why are you using WP-PageNavi for number based pagination. WordPress offer a way to accomplish that. BTW here is the full query for you to use in home.php
Please use this code I faced same problem then i implemented this
Hope it helps you too.
Using home.php doesn’t sound like a good idea, but if it is the only query in the page, you might have to add a couple of things. The following usually works for paginating a static page:
Add:
But you also have to add one more argument to your query arguments in your template part to enable pagination:
Your final code on the template would be:
Why don’t you force the pagination by adding the following code like so:
Check this link: http://codex.wordpress.org/Function_Reference/query_posts#Pagination