WordPress.org

Ready to get started?Download WordPress

Forums

category__not_in sometimes includes 1st post of excluded cateogry (2 posts)

  1. sagamore
    Member
    Posted 2 years ago #

    I want to exclude posts from categories 3, 8, and 15 from a search of posts in the last 30 days. The following code works, except that the most recent post in category 3 and the most recent post of category 15 are not excluded. They show up in the results, but all the other posts in those categories are excluded. All posts from other categories are included, as they should be. I don't know why are these two posts being included. (I have checked, and each of these posts is in just one category -- the one to be excluded.)

    My code is at http://pastebin.com/AEn3rrEv. How can I fix this? Thanks.

  2. Orin
    Member
    Posted 2 years ago #

    That is kind of weird. Hm. I'd first suggest moving away from category__not_in; it's become more problematic since 3.1.

    where you have
    array( 'category__not_in' => array( '3', '8', '15' ) )

    try changing it to
    array( 'cat' => '-3,-8,-15' ) )

Topic Closed

This topic has been closed to new replies.

About this Topic