Sometimes it’s necessary to showcase your video in some other part of the page than in the article content, or you just want your users to fill in the videos in a more structured way.
First, activate the function Enable profile videos in Settings > FV Player > Setup tab > Integrations/Compatibility. Then use this code in your theme’s functions.php
file to add a new “Film Videos” box with meta key “film_videos” to all of your posts (not pages though):
/**
* FV Player Video Custom Fields
*/
if( class_exists('FV_Player_MetaBox') ) {
new FV_Player_MetaBox( array(
'name' => 'Film Videos',
'meta_key' => 'film_videos',
'post_type' => 'post',
'display' => true,
'multiple' => true,
'labels' => array(
'edit' => 'Edit Video',
'remove' => 'Remove Video'
)
)
);
}
The videos will appear automatically at the end of the post.
Then you get a new meta box on the post editing screen – it lets you insert new videos and also shows a preview of the video that is stored.
You can also omit the “display” parameter to get more control over how the videos are displayed:
if( class_exists('FV_Player_MetaBox') ) {
new FV_Player_MetaBox( array(
'name' => 'Film Videos',
'meta_key' => 'film_videos',
'post_type' => 'post'
)
);
}
Then you can use this PHP code to show these videos in your post template:
if( class_exists('FV_Player_Custom_Videos') ) {
global $post;
$objVideos = new FV_Player_Custom_Videos( array('id' => $post->ID, 'meta' => 'film_videos', 'type' => 'post' ) );
$objVideos->get_form();
if( $objVideos->have_videos() ) {
foreach( $objVideos->get_videos() AS $video ) {
echo do_shortcode($video);
}
}
}
Please note that in the arguments passed to contructor of FV_Player_Custom_Videos the “type” field doesn’t refer to the “post_type”, but switches between using post meta and user meta.