Support » Themes and Templates » Excluding some posts

Excluding some posts

  • Hello!
    The example shown to exclude some posts on the query_posts() documentation uses a list of excluded posts inside the loop, which is pretty ugly, as if I have shown 4 “special” posts before (imagine a “special” category) and want to show 10 posts later (any category), I’d have to bring 14 posts to make sure all will get shown.

    Is there any way to tweak the query beyond query_posts() (where ID NOT 1 and ID NOT 2 and ID NOT 3 and so on) ?

    Thanks a lot


Viewing 3 replies - 1 through 3 (of 3 total)
  • Have you considered using category to determine what to exclude?

    Here’s a plugin that might help?

    I have a “Special” category, on which I query 4 posts to appear in a different layout on the front page. After that, I must show all posts (from all categories), but not the 4 posts I already showed.
    Currenty, I’m keeping track of the post ids I showed, and then, I fetch max_posts + 4 from the database, and don’t display if the_ID was already displayed.
    I know this can be done in a much cleaner manner using sql directly, but haven’t found a way to tweak wordpress queries in such a low level.

    Any tips ?

    There are some example of using multiple Loops on The_Loops page in the codex.

    At risk of summarizing your initial post (but I don’t completely understand it), couldn’t you do the first loop for 4 posts of a specific cat and then do do a second loop for 14 posts of all cats — use a variable to ignore the first 4 in that second loop while iterating.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Excluding some posts’ is closed to new replies.