• Hi there,

    So basically I’ve got a minor issue I’m struggling to get to the bottom of, and was hoping some kind soul out there somewhere or other may be able to help..!

    I’m having an issue with the archived pages of the ‘Live’ category on my site, Dots & Dashes. All is functioning fine and dandy, ’til I hit page 21 of the archives, at which point I’m getting a ‘Page Not Found’ error…

    Any ideas, anyone..?

    Thanks!
    Josh.

Viewing 15 replies - 16 through 30 (of 39 total)
  • Thread Starter dotsanddashes

    (@dotsanddashes)

    ah you’re right… so before I only had an issue with this particular category, though it now seems to have affected the Blog, Reviews, and the Features… So what do I need to do exactly now..?

    No I checked before that it affected all categories! You just need to find out the ids of those categories and update the is_category if statement to include those categories.

    Thread Starter dotsanddashes

    (@dotsanddashes)

    Ah OK – my bad! But it’s not the exact same coding that needs to go in for each category, is it..?

    Sorry I don’t understand your question. You just need to extend the if statement to include all categories.

    Thread Starter dotsanddashes

    (@dotsanddashes)

    so to do that, I just separate the numbers with commas, right..?

    The issue is then that certain categories need to show more posts than others…

    So the Reviews need to be on six and not four; the Blog on seven; the Live/ Features on four… I tried to alter the Features bit (id 110) but it’s either stuck on the same broken page (page 8) or it’s showing ten features at a time..?

    Use something like

    function custom_posts_per_page( $query ) {
        if ( is_category( 5 ) or is_category( 110 ) ) {
            // Display 4 posts if the category is live or features
            $query->set( 'posts_per_page', 4 );
            return;
        }
        if ( is_category( 7 ) ) {
            // Display 7 posts if the category is blog
            $query->set( 'posts_per_page', 7 );
            return;
        }
        if ( is_category( 8 ) ) {
            // Display 6 posts if the category is reviews
            $query->set( 'posts_per_page', 6 );
            return;
        }
    }
    Thread Starter dotsanddashes

    (@dotsanddashes)

    I’m getting an error on (I think it was) line 406 if I put that piece of code in, at which point the site breaks down…

    So were I to put that function in, what would I then need to do to the individual category php files..?

    Oh dear I can’t see any errors, what is the exact error and file and line number?

    You don’t actually have to do anything to the individual category php files but it is best to remove the custom query
    <?php query_posts(array ( 'cat' => '5', 'posts_per_page' => 4, 'paged' => $paged)); ?>

    Thread Starter dotsanddashes

    (@dotsanddashes)

    that was my fault – didn’t put the code in as it should’ve been and just as the raw, unformatted text…

    So I’ve inserted that new function though it’s all the same as it was before – breaking off at the exact same pages..?

    Should it all snap back to how it should be if I remove those custom queries now..?

    Thread Starter dotsanddashes

    (@dotsanddashes)

    oh wait – I’m now getting ten features per page, too..?

    Are you sure you set the right category ids?

    Thread Starter dotsanddashes

    (@dotsanddashes)

    Erm I had another look into the category ids, and came out with the following:

    function custom_posts_per_page( $query ) {
        if ( is_category( 5 ) or is_category( 110 ) ) {
            // Display 4 posts if the category is live or features
            $query->set( 'posts_per_page', 4 );
            return;
        }
        if ( is_category( 115, 1 ) ) {
            // Display 7 posts if the category is blog
            $query->set( 'posts_per_page', 7 );
            return;
        }
        if ( is_category( 111 ) ) {
            // Display 6 posts if the category is reviews
            $query->set( 'posts_per_page', 6 );
            return;
        }
    }

    The one thing I was wondering – where each tag says ‘if the category is …’ should I try inserting the id as opposed to the name of the category..?

    Thread Starter dotsanddashes

    (@dotsanddashes)

    the blog has both 115 and 1, which is a little confusing..!

    Where I have written

    if the category is

    is just a comment so you can follow what is going on.

    Havve you remembered the line
    add_action( 'pre_get_posts', 'custom_posts_per_page', 1 );

    Is this working now?

    Thread Starter dotsanddashes

    (@dotsanddashes)

    ah OK! So can I remove that, or does it not matter much..?

    And no – I hadn’t remembered that bit, I confess..!

Viewing 15 replies - 16 through 30 (of 39 total)
  • The topic ‘Advanced pages of category not found…’ is closed to new replies.