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

Multisite searches

…other hand, you can adjust the settings for each blog. Enabling the multisite search There are several ways to enable multisite searching. If you want all searches to be multisite searches, you can enable multisite searching from the Relevanssi searching settings. If you want only some searches to be multisite…searches, you need to adjust search forms to include a specific parameter that will enable the multisite searching. See “Changes to the search form” below. Changes to search results templates The search results templates require some changes, otherwise, the permalinks will be wrong. Inside the while (have_posts()) loop, add as……in the same WordPress network, use the searchblogs argument. You can add a hidden input field in the search form, for example. List the desired blog ids as the value. For example, searchblogs=1,2,3 would search blogs 1, 2, and 3. Here’s an example search form: <form action=”https://www.relevanssi.com/” method=”get”> <input id=”s” name=”s”…

Blocking pre and code tags
If your posts have lots of programming code examples in <pre> and <code> tags, those might look pretty bad in…
Martfury
Martfury is a WooCommerce theme that comes with a built-in dropdown search. That’s great, except that as usual the dropdown…

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