Hello both. And sorry Amanda for this late reply. I didn’t receive any notification.
To be honest, I do not remember clearly.
But in my functions.php I have:
// Add Shortcode For Event Date
function start_date_shortcode() {
// Ensure the global $post variable is in scope
global $post;
// Retrieve events
$events = tribe_get_events();
// Loop through the events: set up each one as
// the current post then use template tags to
// display the start date date
foreach ( $events as $post ) {
$postid = get_the_ID();
setup_postdata( $post );
return tribe_get_start_date( $post, false, 'j M, Y - \h H:i' ) . '<br/>';
}
}
add_shortcode('start-date', 'start_date_shortcode');
//** Event Date Shortcodes ***********
//********************************
add_filter( 'vc_gitem_template_attribute_event_date','vc_gitem_template_attribute_event_date', 10, 2 );
function vc_gitem_template_attribute_event_date( $value, $data ) {
extract( array_merge( array(
'post' => null,
'data' => '',
), $data ) );
$atts_extended = array();
parse_str( $data, $atts_extended );
$atts = $atts_extended['atts'];
// write all your widget code in here using queries etc
$startdate = tribe_get_start_date( $post->ID, false, 'j M, Y' ) . '<br/>';
$output = $startdate;
return $output;
}
add_filter( 'vc_grid_item_shortcodes', 'event_date_shortcodes' );
function event_date_shortcodes( $shortcodes ) {
$shortcodes['vc_event_date'] = array(
'name' => __( 'Data Evento', 'sage' ),
'base' => 'vc_event_date',
'icon' => get_template_directory_uri() . '/assets/images/icon.svg',
'category' => __( 'Content', 'sage' ),
'description' => __( 'Data evento', 'sage' ),
'post_type' => Vc_Grid_Item_Editor::postType()
);
return $shortcodes;
}
add_shortcode( 'vc_event_date', 'vc_event_date_render' );
function vc_event_date_render($atts){
$atts = vc_map_get_attributes( 'vc_event_date', $atts );
return '{{ event_date }}';
}
Then, you have to map the shortcode(s) using Visual Composer.
Info here: https://kb.wpbakery.com/docs/learning-more/shortcode-mapper/
Last, using the grid builder (info here: https://kb.wpbakery.com/docs/learning-more/grid-builder/) when you add a new element you will see the shortcode(s) you created.
Hope this helps.