The WP_Term_Query generator tool allows you to easily generate custom queries to retrieve WordPress taxonomy terms based on specific criteria. This tool is perfect for site administrators and developers who need to filter terms such as categories, tags, or custom taxonomies without manually writing SQL queries.
Use our AI-driven interface to craft complex term queries or select from preset options for quick query generation.
Getting Started
Query Variable Name
my_term_query
Define a unique variable name for your query to prevent conflicts with other queries.
Taxonomy
Select the taxonomy you want to filter by (e.g., category
, post_tag
, product_cat
).
Term IDs
Specify the term IDs you want to filter by (e.g., 1
, 2
, 3
). The tool will include only terms that match the selected IDs.
Include Empty
Choose whether to include empty terms in the query result.
Meta Query
Filter terms based on specific metadata, such as a custom meta key and value.
$args = array(
'taxonomy' => 'category',
'include' => array(1, 2, 3),
'meta_query' => array(
array(
'key' => 'featured',
'value' => 'yes',
'compare' => '='
),
),
);
$term_query = new WP_Term_Query( $args );
The WP_Term_Query
class allows you to query WordPress taxonomy terms efficiently. You can retrieve terms by taxonomy, term IDs, metadata, and more. This tool simplifies complex term queries, helping you avoid writing manual SQL.