Reputation: 11
Want to know is there any plugin/hack available for searching custom taxonomies in wordpress?
Directions for any idea will be great.
Upvotes: 0
Views: 5235
Reputation: 1
I've recently developed a plugin that provides custom taxonomy filtering through front-end forms (with dropdowns and an optional text input):
It runs off of its own results page and doesn't directly tie in with the default search.php, nevertheless its still very flexible and allows you to override the plugin pages in your theme.
Upvotes: 0
Reputation: 9997
How about this?
function search_by_tax_filter(&$query)
{
if ($query->is_search)
$query->set('taxonomy', 'taxonomy_name');
}
add_action('parse_query', 'search_by_tax_filter');
Upvotes: 1
Reputation: 22527
Tricky business... This will get you started, this queries the top five tags (taxonomy: post_tag)...
// query the top five tags
$sql = '
SELECT wt.term_id ti,wt.name, wtt.count tc,wtr.term_taxonomy_id tti, wtr.object_id oi
FROM wp_terms wt
INNER JOIN wp_term_taxonomy wtt ON wt.term_id = wtt.term_id
INNER JOIN wp_term_relationships wtr ON wtr.term_taxonomy_id = wtt.term_taxonomy_id
LEFT JOIN wp_posts wp ON wp.ID = wtr.object_id
WHERE taxonomy = \'post_tag\'
GROUP BY name
ORDER BY count DESC LIMIT 0 , 5
';
Upvotes: 0