Support » Fixing WordPress » query_posts question about pagination

  • 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.

    $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.

Viewing 1 replies (of 1 total)
  • 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.

Viewing 1 replies (of 1 total)
  • The topic ‘query_posts question about pagination’ is closed to new replies.