@mariostella
The code I provided can be used as a starting point to provide the functionality you are looking for. The goal of the search updates I made were look for matches that found in a meta field or the post content.
In order to use the meta fields to narrow down the search, you would need to update the plugin code I provided to include an additional AND clause before the full query is assembled and returned:
$term = $wpdb->escape($var_q);
if (!$_GET['sentense'] && Count($search_terms) > 1 && $search_terms[0] != $var_q) {
$query .= " OR ($wpdb->posts.post_title LIKE '{$n}{$term}{$n}')";
$query .= " OR ($wpdb->posts.post_content LIKE '{$n}{$term}{$n}')";
}
//begin new code
if ($_GET['limit_author']) {
$limit_author = $_GET['limit_author'];
$query .= " AND (";
$query .= "($wpdb->postmeta.meta_key = 'author')";
$query .= " AND ($wpdb->postmeta.meta_value LIKE '{$n}{$limit_author}{$n}')";
$query .= ") ";
}
//end new code
if (!empty($query)) {
$where = " AND ({$query}) AND ($wpdb->posts.post_status = 'publish') ";
}
I've not tested it, but it should give you an idea of how and where to update the query.