[wp-hackers] advanced taxonomy query include_children problem

Otto otto at ottodestruct.com
Tue Mar 5 13:48:07 UTC 2013


Using operator => AND is incompatible with wanting to
include_children, because AND is explicitly checking for the given
terms. Think about it, let's say your hierarchy looked like this:

> topics
>> childa
>> childb
> other
>> childc
>> childd

Now, if I said category of topics AND other with include children,
what does that actually mean? Does it have to be in (childa OR childb)
AND (childc OR childd)? The query system isn't sophisticated enough to
parse that sort of thing out. The AND operator takes the given terms
at face value and checks for their existence explicitly.

If you want to use include_children, use operator => IN instead.

-Otto


On Mon, Mar 4, 2013 at 6:51 PM, Haluk Karamete <halukkaramete at gmail.com> wrote:
> I got this query
>
> Array
> (
>     [tax_query] => Array
>         (
>             [0] => Array
>                 (
>                     [taxonomy] => category
>                     [terms] => Array
>                         (
>                             [0] => featured
>                             [1] => science // here, if I replace the term
> "science" with the term "topics" (which happens to be the parent term of
> "science"), I get 0 match.
>                         )
>
>                     [field] => slug
>                     [operator] => AND
>                 )
>
>         )
>
> )
>
> Isn't it that In advanced taxonomy queries like this the include_children
> is supposed to be by default TRUE?
> But even if I were to enforce the include_children as TRUE, results do not
> change. There is something ging on here, I'm unable to see.
>
> The fact of the matter is "topics" category got 0 posts on the dashboard's
> "Categories" page too. That's because we use the "term" only as a place
> holder for its children which are "science", "politics", "finance" and so
> on.
>
> I also tried the none advanced taxonomy route which is using
> the 'category__and' => array('12','3'). No luck same thing. Can't get to
> the children.
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers


More information about the wp-hackers mailing list