Skip to main contentSkip to footer

The event search from The Events Calendar does not work when Relevanssi is enabled. In regular use, it works, but if you try to access the event list directly with a search term in the URL, the search finds nothing.

One solution is to make Relevanssi index the tribe_events post type. Then you can enable Relevanssi in the event search by adding this snippet to your site:

add_action( 'pre_get_posts', function( $q ) {
    if ( isset( $q->query_vars['post_type'] ) && 'tribe_events' === $q->query_vars['post_type'] ) {
        $q->set( 'relevanssi', true );
    }
} );

This function will turn Relevanssi on in all searches for the tribe_events posts.

Another approach is not to index the tribe_events post type. Instead, you can add this filter function:

add_filter( 'relevanssi_prevent_default_request', function( $prevent, $query ) {
    if ( isset( $query->query_vars['post_type'] ) && 'tribe_events' === $query->query_vars['post_type'] ) {
        $prevent = false;
    }
    return $prevent;
}, 10, 2 );

This function will stop Relevanssi from interfering with The Events Calendar search. There’s a bug in the current version of Relevanssi (2.18.0 for Premium, 4.16.0 for free version): if you have enabled Relevanssi in admin searches, the event search won’t work. Disable Relevanssi in admin searches to make the search function.

Your account

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

Search

Popular Resources

Related searches feature

John Blackbourn wrote a cool related searches feature for Relevanssi Premium. It’s included from version 1.7.4. In order to use the related searches, you must have search logging enabled and a good log of past searches. Then add the following code to your search results template in a suitable place:…

Index custom field contents

…the relevanssi_pre_excerpt_content and relevanssi_excerpt_content]}** to filter the content that is used for excerpts. These filter hooks are almost identical: they filter the post content and get the post object and the search query as parameters. The only difference is that relevanssi_pre_excerpt_content runs before the_content is applied, and relevanssi_excerpt_content]}** runs after.…custom fields for the excerpts option. Now Relevanssi will automatically include the custom field content for excerpts. Advanced excerpts from custom fields If you want more control over how the custom fields are used for excerpts, you can use the relevanssi_pre_excerpt_content and relevanssi_excerpt_content]}** to filter the content that is used…matching the search query is only in custom fields and not in post content, Relevanssi won’t be able to use it in excerpts. That is fortunately easy to fix. Just go to Relevanssi settings and the Excerpts and Highlights tab, and enable the “Use custom fields for excerpts” option. Use…

Keyword-based search blocking
Update: In Premium 2.15.0 and later versions, you can do spam blocking from Relevanssi settings. Just navigate to the Spam…

Related Posts:

Comment Section:

7 Comments. Leave new

  • Hi Mikko, so let me known if I understand correctly:
    When I use the Relevanssi search field than is used relenvassi as an engin for the search, but the page that opens is the event calendar search page? Is it correct?
    Thanks in Advance!

    Reply
  • Hello Mikko, thank you for the answer!
    Nope, I’ve done this right now and now the events are shown!
    But when I use the search form then it still goes to the event calendar search 🙁

    Reply
    • Sarah, when everything is set up correctly, that should not matter, as the Event Calendar search should use Relevanssi.

      But if you want to disable the Event Calendar search features completely, that’s a question for the Event Calendar support. I can’t help with that.

      Reply
  • Hello, I’ve tried the first solution, but this code makes event calendar stop working.
    It doesn’t show events anymore.

    I would like to override the event calendar search because it sucks, and I want to use only relevanssi, but any time there is event tribe (or similar words) in the search query, the event calendar search override the relevanssi one.

    Is there a way I can totally exclude the event calendar search?
    Thanks in advance

    Reply

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