• Resolved hannahjohnson438

    (@hannahjohnson438)


    Hi all,

    I’m having some trouble with the events list widget – it looks great, but as we have several events that last a long time (October-February for example) the widget is only showing those events as they have not yet finished. I want to be able to show events that only start AFTER today’s date. I’ve been tearing my hair out trying to find a solution, I tried the below but it just threw up ‘no scheduled events’ instead.

    I’m not fantastically competent with PHP but I’m learning, I know I could just use featured events only but that seems like a bit of a clunky solution

    function tribe_events_list_widget_date_custom(){
    $today = date(“Y-m-d”); //today’s date in MySQL format without the time. Used to compare start date custom field in events.
    array(
    ‘post_type’ => array(‘tribe_events’),
    ‘meta_query’ => array(
    array(
    ‘key’ => ‘_EventStartDate’,
    ‘value’ => $today,
    ‘compare’ => ‘>=’,
    )
    ),
    ‘tax_query’ => array(
    ‘relation’ => ‘OR’, /*without OR both conditions will be met */
    array(
    ‘taxonomy’ => ‘filters’,
    ‘field’ => ‘slug’,
    ‘terms’ => $filtersarray
    ),

    array(
    ‘taxonomy’ => ‘tribe_events_cat’,
    ‘field’ => ‘slug’,
    ‘terms’ => $filtersarray
    ),

    ),
    );

    }
    add_action(‘tribe_get_list_widget_events’,’tribe_events_list_widget_date_custom’);

Viewing 2 replies - 1 through 2 (of 2 total)
  • Hey @hannahjohnson438,

    First off, I would like to apologize for the delay answering.
    We are currently experiencing a higher level of requests than usual.

    Please rest assured that we are working hard at correcting this situation.
    We appreciate your patience while we try to normalize things.

    Thank you for reaching out.

    Just to set expectations, the scope of our support is mostly to get our customers started on the right track and to help them in case of issues. We unfortunately do not provide support for customization.

    With that in mind, it looks like there is already a snippet out there to achieve what you are looking for

    add_filter( 'tribe_events_list_widget_query_args', 'jm_filter_list_widget_query_args' );
    /**
     * Filter the query used for the Event List Widget to show only events starting
     * in the future
     */
    function jm_filter_list_widget_query_args( $args ) {
    
    	$offset = 86400 * 30;
    	$date = date( 'U' ) + $offset;
    
    	$args['eventDisplay'] = 'list';
    	$args['meta_query'] = array(
    		array(
    			'key'     => '_EventStartDate',
    			'value'   => date( 'Y-m-d H:i:s', $date ),
    			'compare' => '>=',
    			'type'    => 'DATETIME',
    		),
    	);
    
    	return $args;
    
    }

    Have a great day!

    Geoff B.

    Hey there! This thread has been inactive for a while so we’re going to go ahead and mark it Resolved. Please feel free to open a new thread if any other questions come up and we’d be happy to help. ??

    Thanks
    Courtney ??

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Displaying events in the list widget after a specific date’ is closed to new replies.