Recurring events dominate site search results

Home Forums Calendar Products Events Calendar PRO Recurring events dominate site search results

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #1311781
    Tim
    Participant

    When using the standard WP site search (not events search) recurring events are dominating the results. If we search for e.g. ‘New Theatre Oxford’ instead of the venue ‘New Theatre Oxford’ coming up the entire search results is made up of a recurring event at that venue.

    Is there a way to prioritise venues over events in the search results and also only show one instance of a recurring event in the WP site search?

    #1314308
    Barry
    Member

    Hi Tim,

    Can you try adding a snippet like this one, either to your theme’s functions.php file or to a custom plugin?

    function tweak_event_search_integration( $query ) {
    	if ( $query->is_search() ) {
    		$query->set( 'post_parent', '0' );
    	}
    }
    
    add_action( 'pre_get_posts', 'tweak_event_search_integration', 100 );

    In essence, it disallows any child posts from being included in the search results. In most cases that ought to do the trick here, though it would also disallow any child pages from being included – which may or may not be a problem for you.

    Might that work here?

    #1314324
    Tim
    Participant

    Thanks Barry that worked brilliantly! I now only have one instance of the recurring event 😀

    Do you know how I can sort the search results by relevance instead of date?

    #1314740
    Barry
    Member

    Hi Tim,

    Glad that worked!

    In terms of improving ordering by relevance, it does already try to do this – to the extent supported by native WordPress search functionality, at least.

    When multiple words are used in the search string, it prioritizes results that have all those words in the same sequence in the post title, followed by those that have all those words in any order in the post title, followed by criteria that tests against the post content and excerpt and last of all it orders by date.

    Depending on what your content contains and what the search terms are (a single word search as an example has less sophisticated ordering than a multi-word search) this may be more or less apparent, but it is there 🙂

    In terms of improving upon it, I’m not sure how much we can offer there – it’s certainly getting into custom coding territory and/or something better delegated to a purpose built search plugin (of which there are a few).

    #1324887
    Support Droid
    Keymaster

    Hey there! This thread has been pretty quiet for the last three weeks, so we’re going to go ahead and close it to avoid confusion with other topics. If you’re still looking for help with this, please do open a new thread, reference this one and we’d be more than happy to continue the conversation over there.

    Thanks so much!
    The Events Calendar Support Team

Viewing 5 posts - 1 through 5 (of 5 total)
  • The topic ‘Recurring events dominate site search results’ is closed to new replies.