Hey Richcc88,
thanks for reaching out! The following workaround will limit the search in metadata.
1.) In search-everything.php file find the function se_build_search_metadata() function and insert $search .= "{$searchand}(meta_key IN ('_sku', 'add_custom_field1_name_here', 'add_custom_field2_name_here'))";
line.
2.) Everything put together should look like this:
// create the search meta data query
function se_build_search_metadata() {
global $wpdb;
$s = $this->query_instance->query_vars['s'];
$search_terms = $this->se_get_search_terms();
$n = ( isset( $this->query_instance->query_vars['exact'] ) && $this->query_instance->query_vars['exact'] ) ? '' : '%';
$search = '';
if ( !empty( $search_terms ) ) {
// Building search query
$searchand = '';
foreach ( $search_terms as $term ) {
$term = addslashes_gpc( $term );
if ( $this->wp_ver23 ) {
$search .= "{$searchand}(m.meta_value LIKE '{$n}{$term}{$n}')";
} else {
$search .= "{$searchand}(meta_value LIKE '{$n}{$term}{$n}')";
}
$searchand = ' AND ';
}
$search .= "{$searchand}(meta_key IN ('_sku', 'add_custom_field1_name_here', 'add_custom_field2_name_here'))";
$sentence_term = esc_sql( $s );
if ( count( $search_terms ) > 1 && $search_terms[0] != $sentence_term ) {
if ( $this->wp_ver23 ) {
$search = "($search) OR (m.meta_value LIKE '{$n}{$sentence_term}{$n}')";
} else {
$search = "($search) OR (meta_value LIKE '{$n}{$sentence_term}{$n}')";
}
}
if ( !empty( $search ) )
$search = " OR ({$search}) ";
}
$this->se_log( "meta where: ".$search );
return $search;
}
As said, this will limit the search results and the plugin will now search in custom fields with names you define only. In the provided code we added _sku for you and two examples (‘_sku’, ‘add_custom_field1_name_here’, ‘add_custom_field2_name_here’) but you can add more fields. Hope this helps!
Please let me know how it goes, take care and have a nice day,
Petra