将视频上传器添加到我的WordPress自定义程序中

努力为我的wordpress主题添加视频上传器, 有人可以帮忙吗?
我在functions.php文件中有这个:

// Andys Video Section$wp_customize-> add_section("Videosection", array( "title" => __("Video Section", "customizer_ads_sections"), "priority" => 20, )); $wp_customize-> add_setting( 'video_upload', array( 'default' => '', 'transport' => 'refresh', 'sanitize_callback' => 'absint', 'type' => 'theme_mod', ) ); $wp_customize-> add_control( new WP_Customize_Media_Control( $wp_customize, 'video_upload', array( 'label' => __( 'Default Media Control' ), 'description' => esc_html__( 'This is the description for the Media Control' ), 'section' => 'Videosection', 'mime_type' => 'video', // Required. Can be image, audio, video, application, text 'button_labels' => array( // Optional 'select' => __( 'Select File' ), 'change' => __( 'Change File' ), 'default' => __( 'Default' ), 'remove' => __( 'Remove' ), 'placeholder' => __( 'No file selected' ), 'frame_title' => __( 'Select File' ), 'frame_button' => __( 'Choose File' ), ) ) ) );

这在我的页面模板上:
< div class="video-container"> < button style="position:absolute; top:50%; left:50%; " onclick="playPause(); return false; "> Click to start< /button> < video loop controls poster="http://test.guerrilla.nz/wp-content/themes/advocate/images/David_Buckingham.jpg"> < ?php echo get_theme_mod( 'video_upload' ) ?> < source src="http://www.srcmini.com/< ?php echo get_theme_mod('video_upload' ) ?> " width="100" type="video/mp4"> < source src="http://www.srcmini.com/< ?php echo get_theme_mod('video_upload' ) ?> " type="video/ogg"> < source src="http://www.srcmini.com/< ?php echo get_theme_mod('video_upload' ) ?> " type="video/ogg"> Your browser does not support the video tag. < /video> < /div>

但是视频没有上传, 有人可以协助吗?
#1这是全部功能:
function andys_theme_customizer( $wp_customize ) {// Andys Video Section$wp_customize-> add_section("Videosection", array( "title" => __("Video Section", "customizer_ads_sections"), "priority" => 20, )); $wp_customize-> add_setting( 'video_upload', array( 'default' => '', 'transport' => 'refresh', 'sanitize_callback' => 'absint', 'type' => 'theme_mod', ) ); $wp_customize-> add_control( new WP_Customize_Media_Control( $wp_customize, 'video_upload', array( 'label' => __( 'Default Media Control' ), 'description' => esc_html__( 'This is the description for the Media Control' ), 'section' => 'Videosection', 'mime_type' => 'video', // Required. Can be image, audio, video, application, text 'button_labels' => array( // Optional 'select' => __( 'Select File' ), 'change' => __( 'Change File' ), 'default' => __( 'Default' ), 'remove' => __( 'Remove' ), 'placeholder' => __( 'No file selected' ), 'frame_title' => __( 'Select File' ), 'frame_button' => __( 'Choose File' ), ) ) ) ); }add_action( 'customize_register', 'andys_theme_customizer' );

#2好的, 谢谢, 所以请尝试将模板中的代码更改为此:
< div class="video-container"> < ?php $id = get_theme_mod('video_upload'); $attr = array( 'src' => wp_get_attachment_url($id) ); echo wp_video_shortcode( $attr ); ?> < /div>

【将视频上传器添加到我的WordPress自定义程序中】看一下文档wp_video_shortcode。

    推荐阅读