I have two custom post type: product and faq. The product post type has a taxonomy product_tag. So now, I want to search for text ‘food’ in both blog and faq and those products having tag as ‘food’.
This is the arguments for the query:
$args = array(
'tax_query' => array(
array(
'taxonomy' => 'product_tag',
'field' => 'slug',
'terms' => 'food'
)
),
'post_type' => array('post', 'faq', 'product'),
'posts_per_page' => 6,
's' => 'food',
'paged' => $paged
);
But I am not getting any result. If I remove the tax_query array from the code, I get the results but not all products having food as tags are displayed. It just search for the text in them.
So, what should be the modification needed so that I get relevant posts here?
For anyone having interest, this is how I solved it: