Last active
May 22, 2016 05:22
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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