WordPress.org

Ready to get started?Download WordPress

Forums

Pagination not working in certain pages (6 posts)

  1. jefflau
    Member
    Posted 3 years ago #

    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 http://www.heruni.com/author/jeffrey 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.

    http://www.kriesi.at/archives/how-to-build-a-wordpress-post-pagination-without-plugin/comment-page-1#comments

    http://www.heruni.com

    Any help would be much appreciated.

    Thanks

  2. jefflau
    Member
    Posted 3 years ago #

    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:

    http://www.heruni.com/author/geraldineh

    One that doesn't:

    http://www.heruni.com/author/jeffrey

    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!

  3. jefflau
    Member
    Posted 3 years ago #

    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.

  4. Paul
    Member
    Posted 2 years ago #

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

  5. keesiemeijer
    moderator
    Posted 2 years ago #

    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;
            $query->set('paged',$paged);
    
    	      return $query;
    }
    return $query;
    }

    If that doesn't work try it with:

    $query->set('posts_per_page', 10);
  6. Paul
    Member
    Posted 2 years ago #

    Thanks!

Topic Closed

This topic has been closed to new replies.

About this Topic