Forums

PLEASE help with category pagination issue (10 posts)

  1. jillsays
    Member
    Posted 8 months ago #

    Hello,
    I've been trying to resolve a category pagination issue for weeks with no luck. I'm trying to display posts from a particular category, one post at a time. The index works, but when I go to page 2, I get a 404 error.

    <?php
    
    // The Query
    query_posts( array ( 'category_name' => 'submissions', 'posts_per_page' => 1 ) );
    
    // The Loop
    while ( have_posts() ) : the_post();
    
    endwhile;
    
    ?>

    That is the code I am using. Would that do the trick?

    I've also tried fixes from people who said this was a permalink issue with wordpress 3+, but none of the fixes have worked.

    Does anyone have any insight to offer? I'm at my wits end!

    Thanks-

  2. Jackson
    Member
    Posted 8 months ago #

    Try this:

    <?php
    $paged = ( get_query_var( 'paged' ) ) ? get_query_var('paged') : 1;
    
    // The Query
    query_posts( array (
        'category_name' => 'submissions',
        'posts_per_page' => 1,
        'paged' => $paged
     ) );
    
    // The Loop
    while ( have_posts() ) : the_post();
    
    endwhile;
    
    ?>
  3. jillsays
    Member
    Posted 8 months ago #

    Thanks for the reply, but nope! Page 2 is still broken with that code, and returns a 404.

  4. duck__boy
    Member
    Posted 6 months ago #

    $paged is a global, so if that code is outside of a function (i.e. 'taxonomy.php' or 'single.php') then just putting 'paged' => $paged should achieve the same results. If you are running that code inside a function the add global $paged; just inside the function.

  5. vtxyzzy
    Member
    Posted 6 months ago #

    If you are using 'pretty permalinks', you may be a victim of the notorious 'Category pagination bug'. Try installing the Category Pagination Fix plugin.

    If it does not help, you can always delete it.

  6. jillsays
    Member
    Posted 6 months ago #

    I tried the category pagination fix - it didn't work!

    And the problem is still ongoing!

    I just completely removed all my pagination plugins, and hard-coded pagination into functions.php - and it is still happening.

    I am really at my wits end!

  7. vtxyzzy
    Member
    Posted 6 months ago #

    I recently tried to help someone else with a pagination problem. Their pagination worked with the default permalinks, but not with 'pretty' permalinks. I was never able to find a cause for them.

    Does your pagination work with plain permalinks?

  8. jillsays
    Member
    Posted 6 months ago #

    I have not tried plain permalinks, because I definitely can't afford to lose the thousands of links I already have on the site... and have no clue how to redirect them all.

    What is strange is that this is a completely intermittent issue. It only happens sometimes - and not others. Sometimes it's page 2, sometimes it's page 8. It has no rhyme or reason - and it doesn't happen to everyone. I still haven't seen it once.

    Could it have something to do with w3 total cache?

  9. vtxyzzy
    Member
    Posted 6 months ago #

    Unless I am mistaken, switching back and forth between default and pretty permalinks will not lose anything. At least that has been my experience.

    I believe that pretty permalinks are built 'on the fly' and not stored anywhere, so switching should not cause problems.

    Perhaps one of the gurus will verify that.

  10. jillsays
    Member
    Posted 6 months ago #

    I don't think it is permalink related. The error never happens on single post pages. It's always just on page 2 (or a random page) of the site after the index.

Reply

You must log in to post.

About this Topic