This website uses cookies to personalize your experience. By using this website you agree to our cookie policy.

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

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #4914
    fpelafpela
    Participant

    Hi,

    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 fpelafpela.
    #4928
    Ernest MarcinkoErnest 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:

    [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

    #4942
    fpelafpela
    Participant

    Hi,

    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
    Frederic

    #4947
    Ernest MarcinkoErnest Marcinko
    Keymaster

    Hi!

    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.

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.