[Plugin: Relevanssi – A Better Search] [Plugin: Relevanssi] Feature request with patch: Phrase searc
-
Relevanssi does search in custom field, but it does not work with phrases (searching for a phrase like “The whole phrase”). Actually the following little patch solves this problem:
Insert
//added by continent7 to make phrase-search in custom field available $query = "SELECT ID FROM $wpdb->posts AS p, $wpdb->postmeta AS m WHERE p.ID = m.post_id AND m.meta_value LIKE '%$phrase%' AND p.post_status = 'publish'"; $docs = $wpdb->get_results($query); if (is_array($docs)) { foreach ($docs as $doc) { if (!isset($phrase_matches[$phrase])) { $phrase_matches[$phrase] = array(); } $phrase_matches[$phrase][] = $doc->ID; } }
in relevanssi_recognize_phrases() (relevanssi.php) right under
$query = "SELECT ID FROM $wpdb->posts as p, $wpdb->term_relationships as r, $wpdb->term_taxonomy as s, $wpdb->terms as t WHERE r.term_taxonomy_id = s.term_taxonomy_id AND s.term_id = t.term_id AND p.ID = r.object_id AND t.name LIKE '%$phrase%' AND p.post_status = 'publish'"; $docs = $wpdb->get_results($query); if (is_array($docs)) { foreach ($docs as $doc) { if (!isset($phrase_matches[$phrase])) { $phrase_matches[$phrase] = array(); } $phrase_matches[$phrase][] = $doc->ID; } }
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘[Plugin: Relevanssi – A Better Search] [Plugin: Relevanssi] Feature request with patch: Phrase searc’ is closed to new replies.