Skip to content

Instantly share code, notes, and snippets.

@cliffordp
Last active November 4, 2020 05:48
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/a7e40bf92d2ca60a9b5dc6b24301d010 to your computer and use it in GitHub Desktop.
Save cliffordp/a7e40bf92d2ca60a9b5dc6b24301d010 to your computer and use it in GitHub Desktop.
Output a single ECP Additional Field's value in TEC's List View after the Venue line. This one is an example of "Owners" field.
<?php
/**
* Output a single ECP Additional Field's value in TEC's List View after the Venue line.
* This one is an example of "Owners" field.
*
* @link https://gist.github.com/cliffordp/a7e40bf92d2ca60a9b5dc6b24301d010 This snippet.
* @link https://share.getcloudapp.com/o0um142w Screenshot.
*
* @param string $file Complete path to include the PHP File.
* @param array $name Template name.
* @param Tribe__Template $template Current instance of the Tribe__Template.
*/
function cliff_list_view_pro_field_owners( $file, $name, $template ) {
if ( ! class_exists( 'Tribe__Events__Pro__Custom_Meta' ) ) {
return;
}
// !!! CHANGE THIS !!!
$label = 'Owners';
$value = Tribe__Events__Pro__Custom_Meta::get_custom_field_by_label( $label );
if ( empty( $value ) ) {
return;
}
$class = sprintf( 'tribe-list-view-custom-field-%s', $label );
printf(
'<div class="tribe-common-b2 %s"><span class="label">%s:</span> <span class="value">%s</span></div>',
esc_attr( $class ),
$label,
$value
);
}
add_action( 'tribe_template_after_include:events/v2/list/event/venue', 'cliff_list_view_pro_field_owners', 10, 3 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment