Home › Forums › Calendar Products › Filter Bar › Overriding eventDisplay in custom filter
- This topic has 4 replies, 2 voices, and was last updated 8 years, 9 months ago by
ite.
-
AuthorPosts
-
June 22, 2017 at 4:46 am #1301621
ite
ParticipantHey, I’m trying to make a filter to choose between upcoming, past and all events in the filter bar. I have made a few extra filters, filtering by year and month, and custom taxonomy, all of which are working as expected (with some exceptions due to ordering), but I can’t get this filter to work.
Essentially, I’m trying to use the list view plus the filters to display a list of events. Default is to show upcoming events, so the eventDisplay-variable should be left empty/default/list. There are also two more options, custom and past, which I use the following function to inject into the query:
protected function pre_get_posts( WP_Query $query ) { global $wpdb; $values = (array) $this->currentValue; $when = $values[0]; $query->set('tribe_event_display', $when); $query->set('eventDisplay', $when); if ($when == "past"){ $query->set('order', 'DESC'); $query->set('orderby', "{$wpdb->postmeta}.meta_value"); } }As you can see, I’ve tried with both tribe_event_display and eventDisplay, but neither work as expected – the output of the list is not affected at all, no matter which option is chosen.
Can you lend a helping hand here?
June 22, 2017 at 4:57 am #1301624ite
ParticipantActually, the other filters aren’t working properly either, the filter for the custom taxonomy only returns upcoming events too – is the only way around this to manually set the start_date and end_date on when using the various filters?
June 23, 2017 at 2:22 pm #1302532Andras
KeymasterHello ite,
Thanks for reaching out with your questions.
I’m limited in supporting customizations, but might be able to give you some pointers.
In your code above you are only changing the order of the events. As you asked in your second post, if you want past events to be shown then you will also need to change the start_date and end_date.
Something like end_date is today, and start_date smaller than today.
Does that help you get started?
Andras
July 15, 2017 at 9:35 am #1321723Support Droid
KeymasterHey 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 -
AuthorPosts
- The topic ‘Overriding eventDisplay in custom filter’ is closed to new replies.
