[wp-hackers] advanced taxonomy query include_children problem
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:
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.
On Mon, Mar 4, 2013 at 6:51 PM, Haluk Karamete <halukkaramete at gmail.com> wrote:
> I got this query
> [tax_query] => Array
>  => Array
> [taxonomy] => category
> [terms] => Array
>  => featured
>  => 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
> 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
More information about the wp-hackers