Support

Home Forums Event Espresso Premium Adding information to – event displayed on calendar- fc-event-inner

Adding information to – event displayed on calendar- fc-event-inner

Posted: June 28, 2018 at 7:51 am


paintforfun

June 28, 2018 at 7:51 am

Hi!
I want to add more information to the event displayed in the calendar, for example: venue. How can I do this?

Thanks!


Josh

  • Support Staff

June 28, 2018 at 9:42 am

Hi,

The name of the event that’s displayed in the calendar is filterable via the WordPress plugin API. So to add the venue name you can add the following code to your site:

function my_custom_calendar_filtered_title( 
    $original_title, 
    $datetime_in_calendar
) {
    $venue_name = '';
    $event = $datetime_in_calendar->event();
    $venues = $event->venues();
    if(is_array($venues)) {
        $venue = reset($venues);
        if( $venue instanceof EE_Venue ){
            $venue_name = ' at ' . $venue->name();
        }
    }
    return $event->name() . $venue_name;
}
add_filter( 
    'FHEE__EE_Datetime_In_Calendar__to_array_for_json__title', 
    'my_custom_calendar_filtered_title', 
    10, 
    2 
);

You can add the above to a functions plugin or into your WordPress child theme’s functions.php file.


paintforfun

July 5, 2018 at 4:44 am

Thank you for this..
Exactly what Im after but I would like to add it under the time of the event rather then in the title.How can I do that?
Thanks!


Josh

  • Support Staff

July 5, 2018 at 6:43 am

In that case you’ll need to hook into a different filter then. e.g.

add_filter( 
    'FHEE__EE_Calendar__get_calendar_events__event_time_html', 
    'my_custom_calendar_filtered_time', 
    10, 
    3 
);
function my_custom_calendar_filtered_time( 
    $original_output, 
    $datetime,
    $event
) {
    $venue_html = '';
    if($event instanceof EE_Event) {
        $venues = $event->venues();
        if(is_array($venues)) {
            $venue = reset($venues);
            if( $venue instanceof EE_Venue ){
                $venue_name = ' at ' . $venue->name();
                $venue_html = '<span class="time-display-block">';
                $venue_html .= '<span>' . $venue_name . '</span>';
                $venue_html .= '</span>';
            }
        }
    }
    return $original_output . $venue_html;
}


paintforfun

July 5, 2018 at 6:44 am

RESOLVED!
much appreciated 🙂

The support post ‘Adding information to – event displayed on calendar- fc-event-inner’ is closed to new replies.

Have a question about this support post? Create a new support post in our support forums and include a link to this existing support post so we can help you.

Event Espresso