I'm trying to implement search, which will look through custom taxonomy terms. I have custom type called "product", and custom taxonomy called "type". When I'm using wordpress standard form it works good except the fact, that it doesn't search in custom taxonomy terms.
So, what I need is: 1. Make WP search through "m_type" taxonomy terms 2. It should use "name" of the term, instead of "slug".
I was trying to include additional query vars to make it look through "slugs" at least.
This code:
$wp_query->query['tax_query'] = array(
array(
'taxonomy' => 'm_type',
'field' => 'slug',
'terms' => 'pen'
)
);
Generates the following SQL:
SELECT SQL_CALC_FOUND_ROWS wp_posts.ID FROM wp_posts INNER JOIN wp_term_relationships
ON (wp_posts.ID = wp_term_relationships.object_id) INNER JOIN wp_postmeta ON
(wp_posts.ID = wp_postmeta.post_id) WHERE 1=1 AND ( wp_term_relationships.term_taxonomy_id
IN (163) ) AND (((wp_posts.post_title LIKE '%pen%') OR (wp_posts.post_content LIKE
'%pen%'))) AND wp_posts.post_type IN ('product') AND (wp_posts.post_status
= 'publish' OR wp_posts.post_author = 1 AND wp_posts.post_status = 'private') AND
(wp_postmeta.meta_key = 'max_price' ) GROUP BY wp_posts.ID
ORDER BY wp_postmeta.meta_value+0 DESC LIMIT 0, 60
So, basically it adds custom taxonomy, search through posts, that have this kind of taxonomy (*wp_term_relationships.term_taxonomy_id IN (163)*) but actually never compares taxonomy term with query string.
Maybe I'm doing all of this wrong?
ll appreciate if you
ll upvote or select it as a right answer. :) – Chirag Swadia