Skip to content

Instantly share code, notes, and snippets.

@cliffordp
Last active May 22, 2016 05:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cliffordp/4912b6e0e5ffc67e312264336f1218b8 to your computer and use it in GitHub Desktop.
Save cliffordp/4912b6e0e5ffc67e312264336f1218b8 to your computer and use it in GitHub Desktop.
Outputs an Additional Field from The Events Calendar PRO by label name and event ID
<?php
/**
* From https://gist.github.com/cliffordp/4912b6e0e5ffc67e312264336f1218b8
*
* Outputs an Additional Field from The Events Calendar PRO by label name and event ID
*
*/
$event_id = get_the_ID(); // https://developer.wordpress.org/reference/functions/get_the_ID/
$field_label = "Instructor Name"; // change to the Field Label you want to get
if ( ! empty( $event_id ) && method_exists( 'Tribe__Events__Pro__Custom_Meta', 'get_custom_field_by_label' ) ) {
$field_value = Tribe__Events__Pro__Custom_Meta::get_custom_field_by_label( $field_label, $event_id );
if ( is_string( $field_value ) && '' != $field_value ) { // have not tested if we need to also allow integer, float, or other !is_array() values
printf( '<div class="tribe-events-custom%s"><strong>%s:</strong> %s</div>',
sanitize_html_class( '-' . $field_label ), // https://developer.wordpress.org/reference/functions/sanitize_html_class/
$field_label,
$field_value
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment