Related Events – Past Events Showing

Home Forums Calendar Products Events Calendar PRO Related Events – Past Events Showing

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #1013289
    Abigail Marshall
    Participant

    When browsing events the “related events” carousel at the bottom of the page sometimes shows events whose date has already passed.

    I would like it to only show upcoming (future) workshops.

    Is there a way to adjust settings on this? (Not sure whether this is a bug or a feature, but I prefer that past events not be displayed that way)

    #1013383
    Brook
    Participant

    Howdy Abigail,

    That is certainly possible. Here is a snippet that does something similar, and with minor modification can do exactly what you want:

    https://gist.github.com/elimn/1e6797dd1a5d8ee666c5

    If you change this line to just ‘now()’ it should only show events from the current date forward:

    strtotime( '-2 month', $event_start_date )

    Does that make sense? That work for you?

    Cheers!

    – Brook

    #1013390
    Abigail Marshall
    Participant

    Thanks, this seems to work — I added that to my functions.php with this code:

    function tribe_related_posts_args_limiter ( $args = array() ) {
    	global $post;
    	$event_start_date = strtotime( $post->EventStartDate );
    	$event_end_date = strtotime( $post->EventEndDate );
    	$date_format = Tribe__Events__Date_Utils::DBDATETIMEFORMAT;
    	$args['eventDisplay'] = 'custom';
    	$args['start_date'] = date_i18n(
    		$date_format,
    		strtotime( 'now()',  $event_start_date )
    	);
    	$args['end_date'] = date_i18n(
    		$date_format,
    		strtotime( '+3 month', $event_end_date )
    	);
    	return $args;
    }
    add_filter( 'tribe_related_posts_args', 'tribe_related_posts_args_limiter', 10, 1 );

    I’ll monitor it for awhile but it seems to be working for now.

    #1013853
    Brook
    Participant

    I am happy that is working! Let us know if you ever need anything else. Cheers!

    – Brook

Viewing 4 posts - 1 through 4 (of 4 total)
  • The topic ‘Related Events – Past Events Showing’ is closed to new replies.