0
/**
* 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 night!
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’m not able to pull the same in the place I want/page etc...
Can someone tell me how to pull? Field link created in post
I tried to pull like that, but like I said, I’m not quite sure yet...
<?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();
?>
how is your loop?
– Caio Felipe Pereira
In fact, really, I haven’t done anything yet loop or anything on the call, because I have no idea what to call when it’s a custom field. A friend told me, which is as follows <? php $image = get_post_meta($post->ID, Imagem', true); ? > ?
– Peter Roberto
if this plugin saves this box as metadata (which I believe it to be), this may be a way
– Caio Felipe Pereira