search query within custom taxonomy term, post title and meta field

You can do everything you need using the search parameters allowed in WP_Query — except searching in the post title only. In order to do that, see this answer.

Make sure to look at the taxonomy and meta subqueries allowed in the args passed to WP_Query.

EDIT: Since you need to select using OR, you have 2 options — you could run 2 queries and merge the 2 post arrays afterwards, or if you are more concerned about performance, you can use a custom query and just execute the SQL you wrote above. Use the global $wpdb object and the function $wpdb->get_results(). In order to make your query not return duplicate results, you should be able to use SELECT DISTINCT.

Leave a Comment