Skip to main contentSkip to footer

Ajax Load More is an infinite scrolling plugin for WordPress. It has a Relevanssi extension, but with the current versions of Ajax Load More (5.5.4.1 as I write this), the extension no longer does anything. The extension relies on a filter hook that does not exist in the plugin.

Instead of the extension, you can make Ajax Load More use Relevanssi by adding this function to your site:

add_filter( 'alm_modify_query_args', function( $args ) {
    $args['relevanssi'] = true;
    return $args;
} );

This function enables Relevanssi in the Ajax Load More queries.

Every time Ajax Load More loads more results, it counts as a new search for Relevanssi logs. If you don’t like that, you can make Relevanssi only log the first Ajax Load More search. If you want that, use these functions instead of the one above:

add_filter( 'alm_modify_query_args', function( $args ) {
    global $rlv_is_offset_query;
    $args['relevanssi'] = true;
    if ( $args['offset'] ) {
        $rlv_is_offset_query = true;
    }
    return $args;
} );

add_filter( 'relevanssi_ok_to_log', function( $ok, $query ) {
    global $rlv_is_offset_query;
    if ( $rlv_is_offset_query ) {
        $ok = false;
    }
    return $ok;
}, 10, 2 );

Now Relevanssi logs each search query only once.

Your account

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

Search

Popular Resources

Multi-part excerpts
Relevanssi Premium 2.11 introduces a new feature: multi-part excerpts. There’s a new setting on the Excerpts & Highlights settings tab,…
ThemeCo
ThemeCo themes use custom codes for dynamic content. Those are not usual shortcodes, and Relevanssi won’t expand them automatically. In…
Index only short numbers
Relevanssi has a minimum word length setting that is set to three characters. Any one- or two-letter words are not…

Related Posts:

Comment Section:

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