WP_Term_Query Generator

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:

The variable used in the code.
Show the term loop.
A single taxonomy name, or a comma separated list of taxonomies.
Return term by name. Use comma separated list to return an array of term names.
Return term by slug. Use comma separated list to return an array of term slugs.
Return specific list with the included term IDs. Use comma separated list to return an array of terms.
Return specific list without the excluded term IDs. Use comma separated list to return an array of terms.
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.
Term ID to retrieve child terms of. If multiple taxonomies are passed, $child_of is ignored.
Parent term ID to retrieve direct-child terms of.
Whether to include terms that have non-empty descendants.
True to limit results to terms that have no children. This parameter has no effect on non-hierarchical taxonomies.
Number of terms to return.
Number of terms to displace or pass over.
Ascending or Descending order.
Sort retrieved terms by.
Return terms matching a specific metadata key.
Return terms matching a specific metadata value.
Whether to return the total count or array of term objects.
Whether to pad the quantity of a term's children in the quantity of each term's "count" object variable.
Set the fields you want to return.
Whether to hide terms not assigned to any posts.
Whether to return terms regardless of ancestry or whether the terms are empty.
Produce this unique cache key when this query is stored in an object cache.
Returm terms with/without caching the meta information.
  Save Snippet
// WP_Term_Query arguments
$args = array(
	'taxonomy'               => array( 'feature_category' ),
);

// The Term Query
$feature_category = new WP_Term_Query( $args );