I am building a search page with a new instance of wp_query
I am passing a string into s
to get a part number which is currently a taxonomy term. Is there a way to include to the taxonomy term in a custom wp_query
? Happy help would be appreciated.
0
votes
1 Answers
0
votes
You can query posts by a taxonomy value like in the example below:
$query_string = 'francis';
$args = array(
'post_type' => 'post',
'tax_query' => array(
array(
'taxonomy' => 'people', // your taxonomy name
'field' => 'slug',
'terms' => $query_string, // the slug you want to search for - which in your case is passed through the query string
),
),
);
$query = new WP_Query( $args );
To access the query string, use get_search_query()
.