GeneralTaxonomyTermSearchInclude & ExcludeDescendantsPaginationOrderCustom FieldsCountReturn FieldsCacheOverviewUse this tool to create custom code for WordPress Term Query with WP_Term_Query class.UsageFill in the user-friendly form.Click the “Update Code” button.Copy the code to your project.Or save it as a snippet and share with the community.ExamplesIf you are still learning how to use this tool, check out the following examples:“Action” movies in “Genre” TaxonomyPerformance: Return only Category ID’s and NamesQuery Variable Name The variable used in the code.Show The Loop YesNo Show the term loop.Taxonomy A single taxonomy name, or a comma separated list of taxonomies.Term Name Return term by name. Use comma separated list to return an array of term names.Term Slug Return term by slug. Use comma separated list to return an array of term slugs.Search Return terms by general search criteria.Term Name Like Return terms with names like the criteria.Term Description Like Return terms with description like the criteria.Include Return specific list with the included term IDs. Use comma separated list to return an array of terms.Exclude Return specific list without the excluded term IDs. Use comma separated list to return an array of terms.Exclude Tree Return specific list without the excluded term IDs along with all of their descendant terms. Use comma separated list to return an array of terms.Child of Term ID to retrieve child terms of. If multiple taxonomies are passed, $child_of is ignored.Parent Parent term ID to retrieve direct-child terms of.Hierarchical Choose...True - DefaultFalse Whether to include terms that have non-empty descendants.Childless Choose...TrueFalse - Default True to limit results to terms that have no children. This parameter has no effect on non-hierarchical taxonomies.Number Number of terms to return.Offset Number of terms to displace or pass over.Order Choose...ASC - DefaultDESC Ascending or Descending order.Order by Choose...Term IDTerm SlugTerm Name (Default)Term DescriptionTerm GroupCountNone Sort retrieved terms by.Custom Field Key Return terms matching a specific metadata key.Custom Field Value Return terms matching a specific metadata value.Count Choose...CountArray of term objects - Default Whether to return the total count or array of term objects.Pad Counts Choose...True - DefaultFalse Whether to pad the quantity of a term's children in the quantity of each term's "count" object variable.Return Fields Choose...CountArray of Term Objects (Default)Array of Term IDsArray of Term NamesArray of 'id=>name'Array of 'id=>slug'Array of 'id=>parent' Set the fields you want to return.Hide Empty Choose...True - DefaultFalse Whether to hide terms not assigned to any posts.Get Choose...AllEmpty - Default Whether to return terms regardless of ancestry or whether the terms are empty.Cache Domain Produce this unique cache key when this query is stored in an object cache.Cache Term Meta Choose...True - DefaultFalse Returm terms with/without caching the meta information. Update Code Save Snippet
// WP_Term_Query arguments $args = array( ); // The Term Query $term_query = new WP_Term_Query( $args );