Skip to content

Instantly share code, notes, and snippets.

@cliffordp
Created November 6, 2018 23:08
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/376e8c204ccd34ec78fbc38d519350ef to your computer and use it in GitHub Desktop.
Save cliffordp/376e8c204ccd34ec78fbc38d519350ef to your computer and use it in GitHub Desktop.
Events Calendar PRO: Add {pro_addl_fields} variable to the tribe_event_inline shortcode.
<?php
/**
* Events Calendar PRO: Add {pro_addl_fields} variable to the tribe_event_inline shortcode.
*
* @see cliff_render_pro_addl_fields_within_inline_shortcode()
*
* @link https://gist.github.com/cliffordp/376e8c204ccd34ec78fbc38d519350ef This snippet.
* @link https://theeventscalendar.com/knowledgebase/embedding-single-events-tribe_event_inline-shortcode/
* @link https://theeventscalendar.com/knowledgebase/pro-additional-fields/
*/
function cliff_add_pro_addl_fields_to_inline_shortcode( $placeholders ) {
if (
method_exists( 'Tribe__Events__Pro__Single_Event_Meta', 'additional_fields' )
&& function_exists( 'cliff_render_pro_addl_fields_within_inline_shortcode' )
) {
$placeholders['{pro_addl_fields}'] = 'cliff_render_pro_addl_fields_within_inline_shortcode';
}
return $placeholders;
}
/**
* Render an event's PRO Additional Fields template for a given Event ID, as part of the custom {pro_addl_fields}
* variable for the tribe_event_inline shortcode.
*
* @see cliff_add_pro_addl_fields_to_inline_shortcode() This function must go hand-in-hand.
* @see Tribe__Events__Pro__Single_Event_Meta::additional_fields() The functionality we are mimicking.
* @see Tribe__Events__Pro__Shortcodes__Inline__Parser::process() This only works because `call_user_func()` passes its `$id` parameter.
*
* @param int $event_id
*/
function cliff_render_pro_addl_fields_within_inline_shortcode( $event_id = 0 ) {
tribe_get_template_part(
'pro/modules/meta/additional-fields', null, [
'fields' => tribe_get_custom_fields( $event_id ),
]
);
}
add_filter( 'tribe_events_pro_inline_placeholders', 'cliff_add_pro_addl_fields_to_inline_shortcode' );
@danuup1
Copy link

danuup1 commented Oct 27, 2022

Hi thanks for this great snippet.
How should I insert the field inside the shortcodes in revolution slider?
My additional field is:
name = "custom-field [_4]" value = "NewDate"

The shortcodes is: [tribe_event_inline id={{id}}]{pro_addl_fields:custom-field_4]}[/tribe_event_inline] but it does not work.

Can you help me. Thanks

@cliffordp
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment