Past events don't show up in wp search results

Home Forums Calendar Products Events Calendar PRO Past events don't show up in wp search results

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #961267
    James Lavine
    Participant

    Hi, when I used wp search on my site in it’s most default state, all posts and events (past and present) display.

    But, when attempting to limit the search to only the tribe_events post type with a URL like this: http://pcss-o.org/?s=PTSD&post_type=tribe_events …only current and future events will display (no past events).

    The search form is in the top right of this page: http://pcss-o.org/calendar-of-events/

    Any idea what happening to the past events here?

    Thanks!

    #961393
    Barry
    Member

    Hi James,

    When The Events Calendar detects that the main query specifically relates to events a number of things happen in order to help better shape the query and present the results.

    For instance – unless dictated by other query properties – an assumption is made that only upcoming events should be returned. Generally, when dealing with events, this is a sensible default.

    Additionally – though your particular theme may force the use of a different template – the empty search results will be presented within an event view.

    I’m curious: what are your goals here? Do you need an event-specific search that covers all events, past and present? Are you wanting these results to show within a standard WordPress search results page?

    #961837
    James Lavine
    Participant

    Hi Barry,

    Thanks for your response. I should have been more clear about my goal, haha. To answer your questions:

    Do you need an event-specific search that covers all events, past and present? Yes!
    Are you wanting these results to show within a standard WordPress search results page? Yes!

    The results are already showing in a standard WordPress search results page, so we’re halfway there. And I do agree that when searching for events, only showing future event’s is a sensible default…but is there a way around it?

    Thanks!

    #961888
    Barry
    Member

    Hi James,

    It should be possible to workaround this.

    The tribe_events_pre_get_posts action hook provides an opportunity to modify the query object in relation to event queries.

    You could use this to test and see if various conditions like is_search are true then set the query’s eventDisplay property to custom (otherwise it defaults to “list”, which assumes you only want upcoming events).

    add_action( 'tribe_events_pre_get_posts', 'custom_event_search' );
    
    function custom_event_search( $query ) {
        if ( $criteria_met ) $query->set( 'eventDisplay', 'custom' );
    }

    The above code shows the basic form of this sort of change (though you’ll need to fill out the missing detail, of course).

    #965065
    Barry
    Member

    Hi!

    It’s been a while so I’m going to go ahead and close this topic.

    • Need help with anything else? Go right ahead and post a new topic, one of the team will be only too happy to help
    • Still need help with this issue and need to re-open it? Again, please simply create a new topic and link to this one to provide the team with some context

    Thanks!

Viewing 5 posts - 1 through 5 (of 5 total)
  • The topic ‘Past events don't show up in wp search results’ is closed to new replies.