WordPress.org

Ready to get started?Download WordPress

Forums

query_posts question about pagination (2 posts)

  1. vaguelydissatisfied
    Member
    Posted 5 years ago #

    One of my post category ID's is 4. I'm trying to get posts from that category to appear only on pages 2 and above, and keep them off the first page of my blog (e.g. I don't want them to appear on my blog's front page, but I'd like them to appear in my "older posts" when the viewer navigates to them.) This is what I've been able to come up with so far; I realize it's incomplete.

    <?php
    $page = (get_query_var('paged')) ? get_query_var('paged') : 1;
    query_posts("cat=-4,-28&paged=$page&posts_per_page=5&offset=1"); ?>

    I'm wondering if there's some code I can add to it to specify that 'query_posts("cat=-4 etc.' should only apply to the first page of my blog. Right now it's acting like a "switch" that doesn't allow me to display posts from that category at all. Thanks.

  2. stvwlf
    Member
    Posted 5 years ago #

    It might be easier to set up two loops. The first loop would have its own query_posts line, and would display the 1st five posts. Does not need any paging logic.

    The second loop would have the query_posts parameters for paging and cat 4. and an offset of 5 to skip the 5 posts the first loop displayed.

Topic Closed

This topic has been closed to new replies.

About this Topic