WIP: Query Loop: Problem with tax_query and include_children

Bricks Version: 1.6.2

I think there is an issue with the query loop’s tax_query:

By default the “Include children” option in the Query Loop settings is disabled.

CleanShot 2023-01-19 at 16.44.40

With the option being disabled the include_children parameter is not included in the generated tax_query at all.

The problem is that the default value for the include_children parameter (if not explicitly set) is true (see WP_Query | Class | WordPress Developer Resources).

Because of this there is currently no possibility to exclude the children using the Query Loop (without using the query_vars hook to fix the tax_query) – the children are always included.

  1. If you leave the option disabled in Bricks the query parameter is omitted which results in WP’s default value being used. Which is true.
  2. If you enable the option in Bricks the query parameter is explicitly added with a value of true.

Hope my explanation was understandable. :sweat_smile:

1 Like

Hi @aslotta ,

Thank you so much for the detailed explanation.
Understand the problem.
Seems like the Include children should change to Exclude children (set false to include_children param) will be making more sense, agree?


In my opinion it would be the „most correct“ way (looking at the official WP_Query documentation) to have the switch in Bricks being enabled by default. In this case the include_children parameter would not have to be included in the generated query at all since it is the default WP_Query behavior to include the children.

Only if the Bricks user then disables the toggle explicitly the parameter should be included in the query with a value of false.

Reading your answer again… it is the same as mine. Just switching from include to exclude. So yes. Either way would work. Mine is just more of a 1:1 copy to the original behavior. :relaxed:

Thanks in advance, Jenn!