• 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;
    				}
    			}

    https://www.ads-software.com/extend/plugins/relevanssi/

Viewing 3 replies - 1 through 3 (of 3 total)
  • since custom post types became an integral part of wordpress, it would be very useful to have this in a future release of relevanssi! ??

    Plugin Author Mikko Saari

    (@msaari)

    Yeah, I’ll probably grab this for some future version of Relevanssi. Thanks, David!

    Phrase-search seem to work now with relevanssi! ??

    In some cases I get a php warning like this:

    Warning: preg_replace() [function.preg-replace]: Unknown modifier '2' in /var/www/www.domain.de/wp-content/plugins/relevanssi/relevanssi.php on line 1886

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.