Home › Forums › Product Support Forums › Ajax Search Pro for WordPress Support › Custom field search only and search problem
- This topic has 3 replies, 2 voices, and was last updated 10 years, 12 months ago by
Ernest Marcinko.
-
AuthorPosts
-
June 5, 2015 at 8:03 pm #4914
fpela
ParticipantHi,
sorry but I have some problems to use you wonderfull plugin.
1) I have made a lot of post with some information and a custom field for all the post. I only want to make a research in the custom field without searching in the post. If I desactivate post I have no answer for my search, and if I activate search in post I have answer with the custom field, but answer for other word in the post too (and I don’t want that)2) I have some index like 10.102A and 10.102Aa ….
It is possible with the same search instance to have a answer for only 10.102A (exact word) or 10.102Axxx (all the index that begin with 10.102A…)thx for your work
-
This topic was modified 11 years ago by
fpela.
June 8, 2015 at 1:19 pm #4928Ernest Marcinko
KeymasterHi!
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:
[php] (".$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 . "’)";[/php]change those lines to this (so there is an extra line):
[php] (".$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 . "’)";[/php]Then, you will have to change the search keyword logic to “Or with exact keyword matches” on the General Options -> Behavior panel: http://i.imgur.com/jvCImiI.png
June 8, 2015 at 8:12 pm #4942fpela
ParticipantHi,
I try for the second point,
but for the first point that doesn’t work for me. I have done exactly what you say, but in this case the search with index is working (but not all the results ?) and if I put a title word or a post word there is results to ???
I give you access to my site in an other question if you want and can check,thx
FredericJune 9, 2015 at 10:33 am #4947Ernest Marcinko
KeymasterHi!
The fulltext search was used, that’s why it didn’t work. It’s a known bug, it will be corrected in the upcoming version. I’ve corrected it on your site as well.
I’ve also implemented the second part, so you don’t have to edit the code. The plugin should search only the selected custom field – exact word matches or words beginning with the search term.
-
This topic was modified 11 years ago by
-
AuthorPosts
- You must be logged in to reply to this topic.