Well if you are referring to what are the query string keys are, it will depend on the taxonomy you are working with, for
- categories: you are looking for
?cat=cat_id
- tags: you are looking for
?tag=tag_slug
- custom taxonomy: it depends on the slug of the tax but it will look like
?taxonomy_slug=item_slug
Check the definition of the default WP query vars keys for more info
EDIT
As per you comment, I thought I would share this too. If you need/want to search by term_id
(regardless of custom tax or not) you would need to add a custom query string (query vars) and modify the main query to do so.
Here’s how you could do this
// Add your custom query var so WP can listen for that query string too
add_filter( 'query_vars', 'my_add_custom_query_vars' );
function my_add_custom_query_vars( $vars ){
$vars[] = 'my_var';
return $vars;
}
// Then modify the query to include all taxonomies, searching by tax ID
add_action( 'pre_get_posts', 'my_custom_query' );
function my_custom_query( $query ){
$my_id = absint( get_query_var( 'my_var' ) ); // retrieve the var defined above
$tax_query_args = array(
array(
'field' => 'term_taxonomy_id',
'terms' => $my_id,
),
);
$query->set( 'post_type', 'any' );
$query->set( 'tax_query', $tax_query_args );
}
My example could be expanded to listen for multiple term_id
so you could use a query string like ?my_var=1,2,3
to return any posts within term_id
1 OR 2 OR 3
or ?my_var=1+2+3
to return any posts within term_id
1 AND 2 AND 3
. But as a general basic concept, this is how you would do it.