1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
|
add_filter( 'vc_grid_item_shortcodes', 'my_module_add_grid_shortcodes' );
function my_module_add_grid_shortcodes( $shortcodes ) {
$shortcodes['vc_custom_post_meta'] = array(
'name' => __( 'vc_news_post_medias', 'my-text-domain' ),
'base' => 'vc_custom_post_meta',
'category' => __( 'Content', 'my-text-domain' ),
'description' => __( 'Show custom post meta', 'my-text-domain' ),
'post_type' => Vc_Grid_Item_Editor::postType(),
);
return $shortcodes;
}
// output function
add_shortcode( 'vc_custom_post_meta', 'vc_custom_post_meta_render' );
function vc_custom_post_meta_render() {
$id = "{{ post_data:ID }}";
echo $id; // id vaut 1623
echo intval($id); // id vaut 0
echo (int)$id; // id vaut 0
} |
Partager