General Taxonomy Term Search Include & Exclude Descendants Pagination Order Custom Fields Count Return Fields Cache Overview Use this tool to create custom code for WordPress Term Query with WP_Term_Query class. Usage Fill 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. Examples If you are still learning how to use this tool, check out the following examples: “Action” movies in “Genre” Taxonomy Performance: Return only Category ID’s and Names Query Variable Name The variable used in the code. Show The Loop Yes No 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 - Default False Whether to include terms that have non-empty descendants. Childless Choose... True False - 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 - Default DESC Ascending or Descending order. Order by Choose... Term ID Term Slug Term Name (Default) Term Description Term Group Count None 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... Count Array of term objects - Default Whether to return the total count or array of term objects. Pad Counts Choose... True - Default False Whether to pad the quantity of a term's children in the quantity of each term's "count" object variable. Return Fields Choose... Count Array of Term Objects (Default) Array of Term IDs Array of Term Names Array of 'id=>name' Array of 'id=>slug' Array of 'id=>parent' Set the fields you want to return. Hide Empty Choose... True - Default False Whether to hide terms not assigned to any posts. Get Choose... All Empty - 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 - Default False 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 );