Reply To: Custom field search only and search problem

Home Forums Product Support Forums Ajax Search Pro for WordPress Support Custom field search only and search problem Reply To: Custom field search only and search problem

#4928
Ernest Marcinko
Ernest Marcinko
Keymaster

Hi!

1. You have do deactivate the search in content, title, excerpt: https://i.imgur.com/gB6oRf0.png

2. Well, only with a modification to the code. The exact word match is implemented, but the “word beginning with” is not. So open up the wp-content/plugins/ajax-search-pro/includes/search/search_content.class.php file and go to lines 564-567 where you should see this:

   (".$pre_field.$wpdb->postmeta.".meta_value".$suf_field." LIKE $pre_like'% " . $word . " %'$suf_like
OR  ".$pre_field.$wpdb->postmeta.".meta_value".$suf_field." LIKE $pre_like'" . $word . " %'$suf_like
OR  ".$pre_field.$wpdb->postmeta.".meta_value".$suf_field." LIKE $pre_like'% " . $word . "'$suf_like    
OR  ".$pre_field.$wpdb->postmeta.".meta_value".$suf_field." = '" . $word . "')";

change those lines to this (so there is an extra line):

   (".$pre_field.$wpdb->postmeta.".meta_value".$suf_field." LIKE $pre_like'% " . $word . " %'$suf_like
OR  ".$pre_field.$wpdb->postmeta.".meta_value".$suf_field." LIKE $pre_like'" . $word . " %'$suf_like
OR  ".$pre_field.$wpdb->postmeta.".meta_value".$suf_field." LIKE $pre_like'% " . $word . "'$suf_like
OR  ".$pre_field.$wpdb->postmeta.".meta_value".$suf_field." LIKE $pre_like'%" . $word . "'$suf_like
OR  ".$pre_field.$wpdb->postmeta.".meta_value".$suf_field." = '" . $word . "')";

Then, you will have to change the search keyword logic to “Or with exact keyword matches” on the General Options -> Behavior panel: https://i.imgur.com/jvCImiI.png

Best,
Ernest Marcinko

If you like my products, don't forget to rate them on codecanyon :)