1

I'm having an issue with pagination on the static blog page. Under Settings > Reading, "Posts page" is set to a static page. "Blog pages show at most" is set to 10 posts. The first ten posts show up fine, but the pagination doesn't work (returns a 404 for "Previous posts"-link).

I've searched for an answer to this problem, it seems to be fairly common and even mentioned in the WP Codex, although for static Front Page (as opposed to statics Posts page)(http://codex.wordpress.org/Class_Reference/WP_Query#Pagination_Parameters). However all the solutions (involving modyfying/filtering the default query) haven't been working for me, e.g:

$paged = (get_query_var('page')) ? get_query_var('page') : 1;
$args = array('post_type'=>'post','posts_per_page'=>10,'paged'=>$paged);
query_posts($args);

OR

function qm_blog_pagination( $query ) {
    if ( $query->is_home() && $query->is_main_query() ) {
        $paged = (get_query_var('page')) ? get_query_var('page') : 1;
        $query->set( 'paged', $paged );
    }
}
add_action( 'pre_get_posts', 'qm_blog_pagination' );

Any ideas? Would be greatly appreciated.

Thank you, Pim

  • if the main query has more than 10 posts and you get a 404 on the 2nd page, then there's some information missing here. something is modifying the main query to make the 2nd page not contain any posts. do you have this issue with an unmodified core-bundled theme? – Milo May 21 '14 at 1:52
  • Don't have this issue with twentyfourteen out-of-the-box. But I compared the two wp_queries (mine and twenty fourteen) and they look pretty similar, can't immediately spot the difference. Here's a var_dump of WP_query: pastebin.com/r1Aaxdtg – Pim May 21 '14 at 9:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.