テーマのfunctions.phpあたりで、posts_joinとposts_whereなんかのフィルターフックを使って検索条件を変更すればできないことはないです。
以下のコードは参考までに。
function custom_search_join($join) {
global $wpdb;
if (is_search()) {
$join .= "LEFT JOIN $wpdb->term_relationships ON $wpdb->posts.ID = $wpdb->term_relationships.object_id ";
$join .= "INNER JOIN $wpdb->term_taxonomy ON $wpdb->term_relationships.term_taxonomy_id = $wpdb->term_taxonomy.term_taxonomy_id ";
$join .= "INNER JOIN $wpdb->terms ON $wpdb->terms.term_id = $wpdb->term_taxonomy.term_id ";
}
return $join;
}
add_filter('posts_join', 'custom_search_join');
function custom_search_where($where) {
global $wpdb, $wp_query;
if (is_search() ) {
$where = preg_replace("/ OR \(.*post_content LIKE '.*'\)\)\)(.*)/", "))\\1", $where);
$where .= " AND ($wpdb->terms.name LIKE '%" . $wp_query->query_vars['s'] . "%') ";
}
return $where;
}
add_filter('posts_where', 'custom_search_where');
解答ありがとうございます。
wordpress内検索の機能拡張については比較的情報も多く、プラグインも充実してきているので簡単に実装することができますが、制限するとなるとなかなかうまくいかなくて。
本当に、ありがとうございます。