datepicker filter single date

Home Forums Ticket Products Event Tickets Plus datepicker filter single date

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #1182487
    Josh
    Participant

    When selecting a date in the datepicker it returns all events from that day forward unless “day view” is selected. Is it possible for the events listed to be limited to just the selected date in list or photo view as well?

    #1183721
    Nico
    Member

    Hey Josh,

    Thanks for getting in touch with us! I can help you here ๐Ÿ™‚

    Actually I’m working on a very similar customization for another customer. I hope to have this ready today (or tomorrow), when I have a working version I’ll send it your way!

    Best,
    Nico

    #1184420
    Nico
    Member

    Thanks for the patience while I worked on this Josh!

    Please try pasting the following code in your theme’s (or child theme’s) functions.php file:


    /* Tribe, limit tribe bar date search to one day */
    add_action( 'tribe_events_pre_get_posts', function( $query ) {
    $ajax_or_main = ( defined( 'DOING_AJAX' ) && DOING_AJAX ) || $query->is_main_query();

    if ( ! $ajax_or_main || empty( $_REQUEST['tribe-bar-date'] ) ) {
    return;
    }

    if ( ! preg_match( '/^[0-9]{4}-[0-9]{2}-[0-9]{2}$/', $_REQUEST['tribe-bar-date'], $matches ) ) {
    return;
    }

    $end_date = date('Y-m-d', strtotime( $matches[0] . ' +1 day') );

    $query->set( 'end_date', $end_date);
    } );

    Please let me know if it works for you,
    Best,
    Nico

    #1185206
    Josh
    Participant

    Thanks, this is perfect. Very much appreciated.

    #1185233
    Nico
    Member

    Stocked to hear this worked for you Josh ๐Ÿ™‚

    Iโ€™ll go ahead and close out this thread, but if you need help with anything else please donโ€™t hesitate to create a new one and we will be happy to assist you.

    Best,
    Nico

Viewing 5 posts - 1 through 5 (of 5 total)
  • The topic ‘datepicker filter single date’ is closed to new replies.