Term queries should consider include_children =>false

Previously 'include_children' => false was added to almost every taxonomy query on WordPress.com. When a term query is processed, WordPress first looks to see if the term is shared. When global terms were enabled on WordPress.com (before the 4.4 merge) this would always return true.

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 4.4 Terms have all been split on WordPress.com 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. In some cases this change means that queries that used to return almost instantly will time out. We therefore now recommend 'include_children' => false to be added to all taxonomy queries when possible.

In many instances where the wanted behaviour 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 that it’s parent term is also added. A one time WP CLI command might be needed to ensure previous data integrity.

Ready to get started?

Drop us a note.

No matter where you are in the planning process, we’re happy to help, and we’re actual humans here on the other side of the form. 👋 We’re here to discuss your challenges and plans, evaluate your existing resources or a potential partner, or even make some initial recommendations. And, of course, we’re here to help any time you’re in the market for some robust WordPress awesomeness.