[wp-testers] possible category__not_in bug

Philip M. Hofer (Frumph) philip at frumph.net
Mon May 31 06:19:49 UTC 2010


Category problem with children and category__not_in

Scenerio:  I'm trying to get the first post that is in the specific category 
that I want, not the children of it.

Parent category (the cat I want to find the post in) = 17
Child Category of that category = 36

$exclude_array = // array(27) { [0]=>  int(24) [1]=>  int(21) [2]=>  int(23) 
[3]=>  int(10) [5]=>  int(34) [6]=>  int(33) [7]=>  int(32) [8]=>  int(31) 
[9]=>  int(30) [10]=>  int(6) [11]=>  int(22) [12]=>  int(5) [13]=>  int(16) 
[14]=>  int(20) [15]=>  int(37) [16]=>  int(26) [17]=>  int(19) [18]=> 
int(36) [19]=>  int(38) [20]=>  int(35) [21]=>  int(27) [22]=>  int(7) 
[23]=>  int(25) [24]=>  int(29) [25]=>  int(18) [26]=>  int(1) [27]=> 
int(28) }

^^ notice [18] => int(36) - These are all categories that I do not want to 
include in this query including children of 17 or otherwise.

 $args = array (
   'category__in' => array(17),
   'category__not_in' => $exclude_array,
   'order' => $sortOrder,
   'showposts' => 1
  );


The results bring up the first post in the category 36., which is a child of 
17, which I purposely excluded.

- Phil 



More information about the wp-testers mailing list