Support » Fixing WordPress » Pagination not working in certain pages

  • Hi guys,

    I’ve been using kriesi’s pagination code below to create pagination for a site I’m developing. And it works fine for almost all my archive pages. The problem I have is when I use it for my author pages. So doesn’t work and the pages just come up as ‘not found’, when i’ve try to go to page 2. I’m so confused at what’s going on, because its working on all my pages and I’ve basically just tried to copy and paste it over, and the loop works fine, but the pagination is broken somewhere.

    How to build a WordPress Post Pagination without plugin

    Any help would be much appreciated.


Viewing 5 replies - 1 through 5 (of 5 total)
  • Okay this is really weird. I’ve just been outputting one of my categories to my author pages to try and debug this problem. And on some of the author profiles, the pagination is broken. On others it works.

    One that works:

    One that doesn’t:

    I can’t think of any reason why this would be happening, they both run the same template, and right now, they’re both running the same loop, not even author-specific loops. So how could this be occuring?? Surely if the pagination was broken, it should be broken in both!

    Thanks in advance anyone that has read this!

    I fixed the problem. I had to use pre_get_posts in my functions and use the main loop without wp_query or query_posts.



    would you be able to explain this further or provide a code example? I am having the same issue!

    Moderator keesiemeijer



    I think it would be something simular to this:

    add_filter('pre_get_posts', 'query_author_archive');
    function query_author_archive($query) {
    if($query->is_archive && $query->is_author){
            $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    	      return $query;
    return $query;

    If that doesn’t work try it with:

    $query->set('posts_per_page', 10);




Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Pagination not working in certain pages’ is closed to new replies.