Only display events by upcoming Start Date

Home Forums Calendar Products Events Calendar PRO Only display events by upcoming Start Date

Viewing 12 posts - 1 through 12 (of 12 total)
  • Author
    Posts
  • #1028753
    Mad Dog
    Participant

    I’d like to only display items in List and Photo views with a current or upcoming start date. These are Courses, and the client isn’t interested in whether they’re “active,” but whether they’re upcoming. Yet we’d still like the end date so people can see how long a course will last.

    I found a function that’s on the right track (https://theeventscalendar.com/support/forums/topic/displaying-events-in-list-view-makes-calendar-look-out-of-date/) but not quite.

    Simply, I want to only display events that have a Start Date of Today or in the future.

    THANKS
    Mad Dog

    #1028797
    Mad Dog
    Participant

    I found this (https://theeventscalendar.com/support/forums/topic/filter-events-with-start-date-after-now/) and the function the user wrote appears to work. Though there’s a note in the thread from support that says Although you should look to adding a main query check: $query->is_main_query() which isn’t included in the function.

    Is there a better way? Should something be modifed? Or did I stumble on a solution proving that a blind squirrel does indeed find a nut once in a while?

    Thanks,
    Mad Dog

    #1029636
    Josh
    Participant

    Hey Mad Dog,

    To clarify, you would like the views to work as intended except you want to exclude events that span multiple days if the start date has already passed?

    If so, it looks like the code example should work. The only thing you’ll want to change is line 5 to be something like:

    
    if ($post_type == 'tribe_events' && $query->is_main_query() ) {
    

    Let me know if this helps.
    Thanks!

    #1032845
    Mad Dog
    Participant

    Thanks! This seems to do the trick on the normal views, but oddly when I Search by Date it’s starting the results a day or two (or earlier that week) which is strange behavior. Is there anything I can add that will cause it to only list events based on their starting date while Searching by Date?

    THANKS!

    #1033244
    Josh
    Participant

    Hey Mad Dog,

    Try changing line #8 from the original snippet from:

    
    if (!empty( $_REQUEST['tribe-bar-date'] ) ) {
    

    to:

    
    if (!empty( $_REQUEST['tribe-bar-date-filter'] ) ) {
    
    

    and see if that works for you on the search date as well.

    Thanks!

    #1033245
    Josh
    Participant

    Also, you’ll need to change the “tribe-bar-date” in line #9 to be “tribe-bar-date-filter” as well.

    Thanks!

    #1033493
    Mad Dog
    Participant

    This reply is private.

    #1034301
    Josh
    Participant

    Hey Mad Dog,

    I’ll need to do some further checking here. Based on the code, it should be checking the date bar date if there is a date there and limiting the display of events to exclude multi-day events that started before the date selected there.

    I’ll need to look at the code to see what the conditional should be there for that variable.

    Thanks!

    #1038982
    Mad Dog
    Participant

    Hi Josh–

    I know you’ve had your hands full with the new version release. I’ve updated everything and only had two small problems….one I got straight, the other George is looking into.

    But this issue still exists. Any progress or thoughts about it?

    Thanks!
    MD

    #1040574
    Josh
    Participant

    Hey Mad Dog,

    I did some further testing on a vanilla WordPress installĀ and the original snippet from the other thread (excluding the additional check for main query added here) seems to work as expected. That check can actually be excluded as long as you aren’t using any other event queries on the page.

    Does the original snippet work for you with a search date added?

    Thanks!

    #1041215
    Mad Dog
    Participant

    You’re right! So the check for the main query is what was throwing it off?

    Seems to work just fine, both for the regular page view and the search.

    THANKS!

    #1041990
    Josh
    Participant

    Hey Mad Dog,

    Not sure exactly what was happening there but the guess is that as soon as the list is reloaded after a date search it may no longer trigger as the main query.

    Glad that it is working for you no! I’ll go ahead and close this thread for now. If you have any further questions, please don’t hesitate to open a new thread.

    Thanks!

Viewing 12 posts - 1 through 12 (of 12 total)
  • The topic ‘Only display events by upcoming Start Date’ is closed to new replies.