Skip to content

Taxonomy queries should set include_children to false

If the term is shared it will not include the children term. If the term is not shared, it will include the children.

As of WordPress 4.4, terms have been split, which means that this now adds 'include_children' => true to almost all taxonomy queries. This can have a very significant performance impact on code that was performant previously and in some cases, queries that used to return almost instantly will time out. Therefore, we now recommend 'include_children' => false to be added to all taxonomy queries when possible.

In many instances where the wanted behavior is to grab all posts that are either the parent or a child term this can be replaced by only querying for the parent term and enforcing inside a save_post() hook that if a child term is added then its parent term is also added. A one time WP-CLI command might be needed to ensure previous data integrity.

Last updated: April 09, 2021