Support » Fixing WordPress » category__not_in sometimes includes 1st post of excluded cateogry

  • 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 How can I fix this? Thanks.

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

Viewing 1 replies (of 1 total)
  • The topic ‘category__not_in sometimes includes 1st post of excluded cateogry’ is closed to new replies.