Exclude recurrent events from search results except from first instance

Home Forums Calendar Products Events Calendar PRO Exclude recurrent events from search results except from first instance

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #821140
    marcjulia
    Participant

    This doesn’t work:

    add_filter( ‘pre_get_posts’, ‘search_loop_control_recurring_events’ );
    function search_loop_control_recurring_events( WP_Query $query ) {
    if ( !is_admin() && $query->is_main_query() ) {
    if ($query->is_search) {
    $query->set( ‘tribeHideRecurrence’, true );
    }
    }
    }

    http://marcjulia.com/meta/?s=coaching
    Any help would be appreciated. thanks in advanced.

    #822699
    Barry
    Member

    Hi!

    We can’t always provide in-depth support for customizations, but I’d be happy to explore this a little with you and see if we can point you in the right direction.

    So, in this case, can you try swapping out your reference to tribeHideRecurrence with hide_upcoming … does that help at all?

    #823768
    marcjulia
    Participant

    Thanks for the quick reply. I understand your support policy for customizations, I agree… but maybe this should come in as a default option. I can’t see the point to get all recurrent events on search results, but sure, maybe it will be useful for someone else.
    Still not working though, I’ll let you know if I find a working solution.

    #824534
    Barry
    Member

    Definitely.

    There are actually a couple of things at play: one is that I was wrong (apologies!) and the query var is indeed tribeHideRecurrence. The other is that the logic which makes use of this will not actually run in the context of a search query.

    You may be able to trigger it to do so, though, by setting an additional property of the query object:

    add_filter( 'pre_get_posts', 'search_loop_control_recurring_events' );
    
    function search_loop_control_recurring_events( WP_Query $query ) {
    	if ( ! is_admin() && $query->is_main_query() ) {
    		if ( $query->is_search ) {
    			$query->set( 'tribeHideRecurrence', true );
    			$query->tribe_is_multi_posttype = true;
    		}
    	}
    }

    Does that help you out here at all?

    #862042
    Barry
    Member

    Hi! It’s been a while so I’m going to go ahead and close this thread. If we can help with anything else, though, please don’t hesitate to create new threads as needed. Thanks!

Viewing 5 posts - 1 through 5 (of 5 total)
  • The topic ‘Exclude recurrent events from search results except from first instance’ is closed to new replies.