Embedding Month and Week view in my-template/tribe-events/single-event.php

Home Forums Calendar Products Events Calendar PRO Embedding Month and Week view in my-template/tribe-events/single-event.php

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #1348200
    Russell Coon
    Participant

    Hello,

    I’m trying to embed the overall calendar on the top of the single event pages. I tried using:

    <?php echo do_shortcode( ‘[tribe_events view=”month”]’); ?> (Which returns nothing)

    and

    <?php tribe_get_template_part( ‘month’ ); ?> (Which returns the calendar template but with an empty calendar)

    Is this possible?

    #1348259
    Andras
    Keymaster

    Hi Russel,

    Thanks for getting in touch!

    Please give me some time until I check if technically it is possible.

    In the code you pasted you have used curly quotes. Those usually don’t work. If that’s the case then try correcting them to straight clothes, like this:

    <?php echo do_shortcode( '[tribe_events view="month"]'); ?>

    Cheers,
    Andras

    #1348325
    Russell Coon
    Participant

    Thank you, I had used straight quotes but when I pasted the code into the forum it changed them to curly for some reason. I look forward to hearing your response.

    #1348340
    Mathew
    Participant

    There may be a handler in place that prevents this. Not to say it’s not doable, with some work. As a side note, [tribe_events_list] embeds just fine in single event. There’s also a GREAT plugin that will create widget areas on single events.

    
    
    	/**
    	 * Handler for the [tribe_events] shortcode.
    	 *
    	 * Please note that the shortcode should not be used alongside a regular event archive
    	 * view nor should it be used more than once in the same request - or else breakages may
    	 * occur. We try to limit accidental breakages by returning an empty string if we detect
    	 * any of the above scenarios.
    	 *
    	 * This limitation can be lifted once our CSS, JS and template classes are refactored to
    	 * support multiple instances of each view in the same request.
    	 *
    	 * @param $atts
    	 *
    	 * @return string
    	 */
    
    #1348550
    Andras
    Keymaster

    Hello Matthew and thanks for chiming in!

    Both of your recommendations are totally viable, thanks!

    @Russel, you can try those, or a colleague was kind enough to whip up the following snippet. This should do it as well:

    add_action( 'tribe_events_before_view', function( $view ) {
        if ( false === strpos( $view, 'src/views/single-event.php' ) ) {
            return;
        }
    
        if ( ! class_exists( 'Tribe__Events__Pro__Shortcodes__Tribe_Events' ) ) {
            return;
        }
    
        $embedded_view = new Tribe__Events__Pro__Shortcodes__Tribe_Events( array(
            'view' => 'month'
        ) );
    
        echo $embedded_view->render_view();
    } );

    Let me know if that does the trick.

    Cheers,
    Andras

    #1348952
    Russell Coon
    Participant

    Yes, that snippet helped and I figured it out. Thank you!

    #1349115
    Andras
    Keymaster

    Awesome! Super stoked to hear!

    Since this is marked resolved I am going to close this ticket, but if you need anything else related to this topic or another please create a new ticket and we’ll be happy to help.

    Cheers,
    Andras

    PS: If you like our plugins, and you didn’t yet do so 🙂 we would be happy to receive a review in the wordpress.org repository. Thanks!
    https://wordpress.org/support/view/plugin-reviews/the-events-calendar/
    https://wordpress.org/support/view/plugin-reviews/event-tickets/

    PS2: We’d be also grateful if you would give us feedback on your satisfaction with support. Just click on one of the classy looking emojis below. 🙂 If you can spare a few words, that’s even better. Doublethanks!

     

Viewing 7 posts - 1 through 7 (of 7 total)
  • The topic ‘Embedding Month and Week view in my-template/tribe-events/single-event.php’ is closed to new replies.