Overriding eventDisplay in custom filter

Home Forums Calendar Products Filter Bar Overriding eventDisplay in custom filter

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #1301621
    ite
    Participant

    Hey, 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?

    #1301624
    ite
    Participant

    Actually, 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?

    #1302532
    Andras
    Keymaster

    Hello 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

    #1321723
    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 4 posts - 1 through 4 (of 4 total)
  • The topic ‘Overriding eventDisplay in custom filter’ is closed to new replies.