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

Indexing term slugs
I have a term who name is for, example, Great Blue Trojans. The slug is GBT.I want to be able…

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