[tribe_events] past month shows empty calendar

Home Forums Calendar Products Events Calendar PRO [tribe_events] past month shows empty calendar

Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #1180142
    Greg Perham
    Participant

    I have a page with [tribe_events] on it. When going directly to a previous month (such as “/calendar/?tribe-bar-date=2016-07”) the calendar is blank. Navigating using the next and previous month links displays correctly.

    #1180737
    Greg Perham
    Participant

    I am wrong about what the problem is exactly. The problem is that /?tribe-bar-date=2016-07 shows a calendar for the current month while displaying a title and previous/next links for the month in the URL. THIS IS COMPLETELY BROKEN.

    #1180742
    Greg Perham
    Participant

    It gets worse. If I click Find Events in the bar with “Events In: 2016-07”, the title changes to “October 2016”, provides a link to September, and shows events for July.

    #1180942
    Greg Perham
    Participant

    It is also true for future dates. “/calendar/?tribe-bar-date=2016-12” shows October’s events instead of December’s, but has the title “Events for December 2016”.

    #1181033
    Greg Perham
    Participant

    Using this as a workaround:

    function fix_tec_shortcode_date( $content='' ) {
    	if( isset($_GET['tribe-bar-date']) ) {
    		$date = $_GET['tribe-bar-date'];
    		if( preg_match( '#[^-0-9]#', $date ) ) return $content;
    		$content = str_replace( '[tribe_events', "[tribe_events date='$date'", $content );
    	}
    	return $content;
    }
    if( class_exists( 'Tribe__Events__Pro__Shortcodes__Register' ) )
    	add_filter( 'the_content', 'fix_tec_shortcode_date', 1 );
    
    #1181047
    Hunter
    Moderator

    Hey Greg,

    Welcome back and thank you for reaching out! Sorry to hear you’re experiencing some issues. I can confirm there is a bug related to the the [tribe_events] shortcode when navigating directly to a past or future month.

    I was, however, unable to reproduce this behavior:

    It gets worse. If I click Find Events in the bar with “Events In: 2016-07”, the title changes to “October 2016”, provides a link to September, and shows events for July.

    Our apologies you’re having to deal with these bugs and rest assured we’re already hard at work on solutions. I’ve linked this thread to the bug report for the developers to review while making improvements. Please stay tuned to our Release Notes and your wp-admin for maintenance release info.

    For the time being, you could add the following snippet to the bottom of your theme’s functions.php file. You can use the following shortcode to implement the code: ⁠⁠⁠⁠[tribe_past_events view=”list”]. Please note it only works on list view.

    function tribe_past_events_shortcode( $atts ) {
    if ( ! class_exists( 'Tribe__Events__Pro__Shortcodes__Tribe_Events' ) ) return '';
    add_action( 'parse_query', 'tribe_past_events_shortcode_modify_query' );
    $shortcode = new Tribe__Events__Pro__Shortcodes__Tribe_Events( $atts );
    return $shortcode->output();
    }

    function tribe_past_events_shortcode_modify_query( $query ) {
    $query->set( 'tribe_is_past', true );
    remove_action( 'parse_query', 'tribe_past_events_shortcode_modify_query' );
    }

    add_shortcode( 'tribe_past_events', 'tribe_past_events_shortcode' );

    Thanks again and please let me know if you have any more questions or concerns. Cheers!

    #1181050
    Hunter
    Moderator

    I tested the code you provided and it seemed to work for me only when navigating to a future month (/?tribe-bar-date=2016-12), but didn’t seem to work for past months (/?tribe-bar-date=2016-07). Did you write that yourself or did another support team member provide it to you? If the latter, please send a link to the thread.

    Thanks again and take care.

    #1181054
    Greg Perham
    Participant

    I added the filter myself because I noticed that the correct events display when the month is set directly in the shortcode.

    I’ll mark this resolved in the hopes that the shortcode will be fixed.

    #1181056
    Hunter
    Moderator

    Greg,

    Thank you for providing that code – I’ve added it to the bug report, so that should hopefully expedite things. Rest assured things will get better with the next release. Thanks again and please feel free to create a new thread if you have any more questions or concerns.

    Try and enjoy your Friday night and I’ll do the same! Cheers:-)

Viewing 9 posts - 1 through 9 (of 9 total)
  • The topic ‘[tribe_events] past month shows empty calendar’ is closed to new replies.