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

Relevanssi Premium as a Composer package

…use the following: https://www.relevanssi.com/update/get_version.php?api_key=XXX&version=2.20.1 The Composer package should look something like this: { “type”: “package”, “package”: { “name”: “relevanssi/relevanssi-premium”, “version”: “2.20.1”, “type”: “wordpress-plugin”, “dist”: { “type”: “zip”, “url”: “https://www.relevanssi.com/update/get_version.php?api_key=XXX&version=2.20.1″ }, } } WP CLI also supports installing plugins from URLs. You can do this to install Relevanssi Premium: wp plugin…If you want to install Relevanssi Premium as a Composer package, you can use the following URL to fetch the latest version: https://www.relevanssi.com/update/fetch_latest_version.php?api_key=XXX Replace XXX with your valid API key. The URL will always return the latest version of the plugin files. If you want a specific version, you can……install https://www.relevanssi.com/update/fetch_latest_version.php?api_key=XXX Both URLs support HTTP basic auth. If you don’t include the api_key parameter, you’ll be prompted for your user name and password. Use your Relevanssi.com account user name (not the login email) as the user name and your API key as the password. These can be stored in…

Results are in strange order
If best results don’t come up first and changing weighting settings doesn’t seem to make any difference, there couple of…
Gutenberg Full Site Editing
There’s a compatibility issue between Relevanssi and Gutenberg Full Site Editing. No results are found when you create a Query…

Related Posts:

Comment Section:

1 Comment. Leave new

Leave a Reply to Alex Cancel 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