Skip to main contentSkip to footer

A surprisingly common problem with Relevanssi is Bible verses. All that meaningful punctuation and single digits make exact matching of Bible verses really difficult for Relevanssi, and when searching for Bible verses, exact results are what matters – hitting something similar is generally not very helpful.

There’s an easy solution, though: use phrases. Wrapping the verse in quotes is going to result in an exact search that finds exactly what is required. Unfortunately expecting all your users to know that is not reasonable. Most users don’t even know what a phrase search is, let alone that you should use one for Bible verses.

The fix is simple: add some code that will automatically wrap all the Bible verse in quotes to make it a phrase. Add this to your theme functions.php and enjoy more precise Bible verse searches:

add_filter( 'relevanssi_modify_wp_query', 'rlv_bible_verse_handler' );
function rlv_bible_verse_handler( $query ) {
    $m = preg_match_all( '/(\d?\s?\w+ \d+:\d+-?\d?)/', $query->query_vars['s'], $matches );
    if ( $m ) {
        foreach ( $matches[0] as $match ) {
            $query->query_vars['s'] = str_replace( trim($match), '"' . trim($match) . '"', $query->query_vars['s'] );
        }
    }
    $query->query_vars['s'] = str_replace( '""', '"', $query->query_vars['s'] );
    return $query;
}

Your account

Not logged in. Log in to see your license details.

Search

Popular Resources

The wrong content gets indexed for a post

Sometimes Relevanssi can get confused and indexes the post content under the wrong post ID. The main symptoms for this are: You can’t find a post with words you know should be in the post Searching for a word returns a post that doesn’t have that word You can confirm…

Voice Search

…page under the “Searching” tab. There are three main controls for this feature: Voice search: Toggles the microphone icon on or off for all search forms on your site. Voice search autosubmit: If enabled, Relevanssi will automatically trigger the search once the user stops talking. If disabled, the text will……class added when the API specifically detects a human voice. Voice search is currently supported by Chrome, Edge, and Safari. Because the technology requires a secure connection, voice search will only appear on sites running over HTTPS. Here is the list of compatible browsers. Note on Firefox: As of now,…Modern search is about accessibility and speed. Relevanssi now includes a Voice Search feature that allows your visitors to search your site using their microphone. Instead of typing, they simply click a microphone icon and speak their query directly into the search bar. This feature is powered by the Web…

Indexing attachment file names
Relevanssi has been working nicely for the normal usecase. But how does one setup indexing of attachment files. When someone…

Related Posts:

Comment Section:

1 Comment. Leave new

Leave a Reply

Your email address will not be published. Required fields are marked *

Fill out this field
Fill out this field
Please enter a valid email address.
You need to agree with the terms to proceed