Display Current Day's Events Using a Shortcode

Home Forums Calendar Products Events Calendar PRO Display Current Day's Events Using a Shortcode

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #1062252
    Chris
    Participant

    Hello,

    I have a need to display the events of the current day as a list. I see there is a day.php which I assume does the trick, but my coding skills are not as required, and I can not find any code that resembles what I need.

    Is there a shortcode that can be filtered using parameters that can show just today’s events?

    Thanks,

    Chris

    #1062559
    Brian
    Keymaster

    Hi,

    Thanks for using our plugins. I can help out here.

    We do not have a feature to show only today’s events, but you could use the Event List Widget and this snippet:

    /*
    * The Events Calendar - Limit the upcoming widget to just event running today
    */
    add_filter( 'tribe_events_list_widget_query_args', 'tribe_modify_list_widget_args', 10, 1 );

    function tribe_modify_list_widget_args ( $args ) {

    $start_date_init = date ( 'Y-m-d' );
    $start_date_end = $start_date_init . ' 23:59:59';

    $args['meta_query'][] = array('key' => '_EventStartDate','type' => 'DATETIME','compare' => '>=','value' => $start_date_init);
    $args['meta_query'][] = array('key' => '_EventStartDate','type' => 'DATETIME','compare' => '<=','value' => $start_date_end);

    return $args;
    }

    Add that coding to your child theme’s functions.php (or parent them) and let me know if that works.

    Thanks

    #1062735
    Chris
    Participant

    Thanks Brian, that code looks great for my needs.

    In looking at it, I assume that will change the Upcoming Widget for all instances on the site, and if I only want to change a single page instance of the widget, the function contents need to be wrapped in a conditional statement identifying the page and allowing it to run only if the page identifier is true.

    Is that correct?

    Thanks again,

    Chris

    #1063154
    Brian
    Keymaster

    Hi,

    Yep this would work on all Event List Widgets.

    This coding worked to target a specific one:

    https://gist.github.com/jesseeproductions/a99528506ec2f42c8e3f

    You would want to change this: tribe-events-adv-list-widget-2

    To the number of the widget you would like to target.

    That can be found in the source code on the front end. I can help with that if you provide a link.

    Thanks

    #1078900
    Support Droid
    Keymaster

    This topic has not been active for quite some time and will now be closed.

    If you still need assistance please simply open a new topic (linking to this one if necessary)
    and one of the team will be only too happy to help.

Viewing 5 posts - 1 through 5 (of 5 total)
  • The topic ‘Display Current Day's Events Using a Shortcode’ is closed to new replies.