How to process shortcodes contained within fields used by the Calendar
When setting up a GravityCalendar feed, you can specify a field to populate the calendar title and description.
Sometimes, these fields contain shortcodes, like the [gv_math] or the [gvlogic] shortcode. By using the code below, these shortcodes will be parsed and displayed correctly on your calendar:
add_filter( 'gravityview/calendar/events', 'gv_calendar_process_field_value_shortcode' );
/**
* Sometimes field values contain shortcodes you want to process. This does that.
*
* @param array $events Array of events to display on the calendar.
*
* @return array $events, but with `title` and `description` keys processed.
*/
function gv_calendar_process_field_value_shortcode( $events ) {
foreach ( $events as $key => $event ) {
$events[ $key ]['title'] = do_shortcode( GVCommon::decode_shortcodes( $event['title'] ) );
$events[ $key ]['description'] = do_shortcode( GVCommon::decode_shortcodes( $event['description'] ) );
}
return $events;
}
Read here how to add these code samples to your website: Where to put code samples.