How to add custom tags

If you have data stored for your events in a custom field or elsewhere (ie. my_custom_field) and you want to include as a template tag (ie. {my_custom_field}) you can do that with a bit of code in a functional plugin or in your child theme’s functions.php.

Replace my_custom_field with the custom field you want to fetch, and identifier with your calendar’s identifier:

  • all-in-one-event-calendar (All-in-one Event Calendar by Time.ly)
  • event-espresso (Event Espresso)
  • event-organiser (Event Organizer)
  • eventon (EventON)
  • events-manager (Events Manager)
  • eventum (Templatic/Eventum)
  • google-calendar-events (Simple Calendar)
  • the-events-calendar (The Events Calendar)
// Add the additional data for each event
function ecn_add_my_custom_field_data( $args ) {
	// Use additional_data to store our extra data
	if ( ! isset( $args['additional_data'] ) )
		$args['additional_data'] = array();
	$args['additional_data']['my_custom_field'] = get_post_meta( get_the_ID(), 'my_custom_field', true );
	return $args;
}
add_filter( 'ecn_create_calendar_event_args-identifier', 'ecn_add_my_custom_field_data' );

// Register the template tag and description
function ecn_add_my_custom_field( $fields, $plugin ) {
	if ( 'identifier' != $plugin )
		return $fields;
	$fields['my_custom_field'] = 'My Custom Field';
	return $fields;
}
add_filter( 'ecn_available_format_tags_display', 'ecn_add_my_custom_field', 10, 2 );