• Resolved adria

    (@adria)


    Hi, I have a loop that shows all recent posts, excluding one category like so:

    `numberposts=-1&cat=-9129&orderby=post_date&showposts=10

    What I would ideally like, is to only exclude the 4 most recent posts in that category (id 9129), but include the rest.

    Any help?

Viewing 5 replies - 1 through 5 (of 5 total)
  • What about using the offset argument?

    See query_posts()

    The offset is definitely useful, but I don’t quite how to do exactly what I want with it: Show ALL categories EXCEPT (offset 4) the most recent posts in a certain category only. If I do:

    numberposts=-1&cat=9129&offset=4&orderby=post_date&showposts=10

    It offsets the most recent 4 posts in category 9129, but doesn’t show posts in all the other categories. If I just did:

    numberposts=-1&offset=4&orderby=post_date&showposts=10 It would exclude the most recent 4 posts regardless of category, which is also not what I want.

    I don’t know how else I could use these parameters to achieve what I want.

    Okay, I understand what you want to do, but you can’t get there with a single query_posts. You’d have to do 2 different queries, one to 4 posts from category 9129 that you want to offset, then using those post IDs construct a 2nd query with post__not_in.

    Thread Starter adria

    (@adria)

    thanks, this got me what I needed. I just made two queries:

    numberposts=-1&cat=9129&offset=4&orderby=post_date&showposts=4

    and

    numberposts=-1&cat=-9129&orderby=post_date&showposts=6

    The first one gets that category I wanted, except the 4 most recent.
    The second one gets the rest of the categories, excluding the category that I got above. Thanks for your help!

    Hi Adria,
    Any chance you could show how exactly you made these two queries?
    I have exactly the same problem as yourself.
    Thanks
    James

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘exclude recent posts in a certain category’ is closed to new replies.