/**
* Video metabox
*/
$videos = new_cmb2_box( array(
'id' => $prefix . 'video_url',
'title' => 'YouTube Vídeo',
'object_types' => array( 'video_destaque_home', ), // Post type
'context' => 'normal',
'priority' => 'high',
'show_names' => true, // Show field names on the left
'cmb_styles' => true, // false to disable the CMB stylesheet
'closed' => false, // true to keep the metabox closed by default
// 'show_on_cb' => 'yourprefix_show_if_front_page', // function should return a bool value
) );
$videos->add_field( array(
'name' => 'Endereço do vídeo do YouTube',
'desc' => 'Insira a url completa de um vídeo do <a href="http://www.youtube.com" target="_blank">YouTube</a>',
'id' => $prefix . 'video_url',
'type' => 'oembed',
) );
Good evening!
I installed CMB2 in my theme and following the documentation I was able to create the field to put video in my Custom Post Type, but I am not able to pull the same in the place I want / page etc ...
Can anyone tell me how to pull? Field link created in the post
I tried to pull it like that, but as I said, I'm not aware yet right ...
<?php
$args = array(
'post_type' => 'video_destaque_home',
'status' => 'publish',
'showposts' => 1,
'orderby' => 'post_date',
);
$query = new WP_Query( $args );
?>
<?php
// Check that we have query results.
if ( $query->have_posts() ) {
// Start looping over the query results.
while ( $query->have_posts() ) {
$query->the_post(); ?>
<div class="qwp-service-video">
<?php get_post_meta($post->ID, 'youtube_video', true ); ?>
</div><!-- /.qwp-service-video -->
<?php
}
}
// Restore original post data.
wp_reset_postdata();
?>