Skip Navigation

[Resolved] Show event in view with query between start & end date

This support ticket is created 4 years, 1 month ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 -
- 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 14:00 – 18:00 13:00 – 18:00 -

Supporter timezone: America/Jamaica (GMT-05:00)

This topic contains 9 replies, has 3 voices.

Last updated by antond-3 4 years, 1 month ago.

Assisted by: Shane.

Author
Posts
#1838597
querie.png

I have an event width startdate 30 October and EndDate 30 December. We just passed the StartDate but the EndDate is in December. But this event is allready hidden ... I have to add a second filter but what I tried It doesn't work.

hidden link

So there is one event starting on 30 October and ends on 30 December. But I can't see this event.

#1838707

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

What are you trying to display?

Current events? Future events (including those in progress)?

It rather depends on what you are trying to display as to how you should set up your filters.

Today, 9 November, which events—specifically—should be shown by this View?

#1838719
events1.jpg

Current Event

There is an event With StarDate on 30th of October till 30th of December and still open ... only not visible on front end.

Events you see now is good but the one I meant isn't visible, there must be Three events visible on frontend
"Actie: geef je club een rondje" is missing

#1839029

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Anton,

The problem is that you've set the eventstartdate to be greater or equal to NOW().

This means that any events that start Today november the 9th and onwards will show up. A filter like this won't allow you to display the event that started on October the 30th.

Perhaps you need to change the start date filter to a static value so that it can check for x amount of months in the past or x amount of weeks in the past.

It won't automatically display the events that have end dates in the future but their start date has already gone.

Thanks,
Shane

#1839087

Hi Shane,

Instead of using "AND" I've used "OR" now.

My issue is resolved now. Thank you!

#1839109

I'm sorry Issue still there

#1839135

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Anton,

Why not use only the end date in the filter?

This will ensure that only posts that have not yet begun or and posts that have not yet ended to show up.

Thanks,
Shane

#1839623
event-end-date.jpg

Hi Shane,

You mean in querie? Doesn't work also 🙁

#1840113

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Anton,

I recalled assisting you with a similar issue where you wanted to hide past event.

As explained in that ticket you will need to use the Hook in order to filter the posts.
https://toolset.com/forums/topic/view-to-show-current-of-future-events-from-the-events-calendar/

Here is the code that you will need to add to your site.

toolset_snippet_security_check() or die( 'Direct access is not allowed' );
/**
 * Filter event query to show future events
 */
function tssupp_filter_event_query( $view_args, $view_settings, $view_id ){
   
  if ( in_array( $view_id, array( 6090 ) ) ) { // Edit view IDs
   
    if ( ! isset( $view_args['meta_query'] ) ) {
      
      $view_args['meta_query'] = array();
    }
      
    $today = strtotime("0:00");
    $meta_query = array(
      
      'key'     =>  '_EventStartDate',
      'value'   =>  date("Y-m-d H:i:s", $today),
      'type'    =>  'DATETIME',
      'compare' =>  '>='
    );
      
    $view_args['meta_query'][] = $meta_query;
   
  }
    
  return $view_args;
}
add_filter( 'wpv_filter_query', 'tssupp_filter_event_query', 101, 3 );

Replace 6090 with the id of your view. This code should allow you to only show the events that have not yet ended.

Thanks,
Shane

#1843271

My issue is resolved now. Thank you!