Reply To: No Results Being Returned For Custom Field Only Search

Home Forums Product Support Forums Ajax Search Pro for WordPress Support No Results Being Returned For Custom Field Only Search Reply To: No Results Being Returned For Custom Field Only Search

#3044
Ernest Marcinko
Ernest Marcinko
Keymaster

Hi!

I see now. So the keywords are stored in the search_terms custom field as “keyword 1, keyword 2, keyword x” – thus comma+space separated.

I made a few modifications on the source code that should respect this rule, so only the whole keyword matches should be returned.
I think it should work now as you described.

I’m attaching the changed lines here for future reference to myself. file search_content.class.php line 167 custom_field search related:


// NOTES: whole word, comma-space-WORD-comma, BOL-word-comma, comma-space-word-EOL
$parts[] = "($wpdb->postmeta.meta_key='$cfield' AND 
            (
                 lower($wpdb->postmeta.meta_value) LIKE '".$s."'
              OR lower($wpdb->postmeta.meta_value) LIKE '%, ".$s.",%'
              OR lower($wpdb->postmeta.meta_value) LIKE '".$s.",%'
              OR lower($wpdb->postmeta.meta_value) LIKE ', ".$s."'
             )
            )";
Best,
Ernest Marcinko

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