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

This topic contains 3 replies, has 2 voices, and was last updated by Ernest Marcinko Ernest Marcinko 8 years, 10 months ago.

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #4914
    fpela
    fpela
    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 8 years, 10 months ago by fpela fpela.
    Attachments:
    You must be logged in to view attached files.
    #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 :)


    #4942
    fpela
    fpela
    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 Marcinko
    Ernest 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.

    Best,
    Ernest Marcinko

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


Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.