Home › Forums › Calendar Products › Events Calendar PRO › Past events don't show up in wp search results
- This topic has 4 replies, 2 voices, and was last updated 10 years, 11 months ago by
Barry.
-
AuthorPosts
-
May 7, 2015 at 12:09 pm #961267
James Lavine
ParticipantHi, 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!
May 8, 2015 at 4:01 am #961393Barry
MemberHi 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?
May 11, 2015 at 9:39 am #961837James Lavine
ParticipantHi 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!
May 11, 2015 at 11:33 am #961888Barry
MemberHi 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).
May 26, 2015 at 6:51 am #965065Barry
MemberHi!
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!
-
AuthorPosts
- The topic ‘Past events don't show up in wp search results’ is closed to new replies.
