我尝试在主题中使用the_custom_header_markup();
在页面顶部创建一个视频循环,就像在基本主题tweetySeventeen中出现的那样,我不知道如何打开视频声音。
答案 0 :(得分:0)
视频由文件/wp-includes/js/wp-custom-header.js
要在主题中自定义它们,您需要覆盖此文件。
1)将此文件复制到您的资产中,从您的网站的根目录写入
cp wp-includes/js/wp-custom-header.js wp-content/themes/[Your Theme]/assets/wp-custom-header.js
2)在[Your Theme]/functions.php
中注册新文件,并添加此代码
add_action( 'wp_enqueue_scripts', 'register_header_script' );
function register_header_script() {
wp_deregister_script( 'wp-custom-header');
wp_register_script( 'wp-custom-header', get_theme_file_uri('/assets/js/wp-custom-header.js'), array( 'jquery-masonry' ), false, 1 );
}
3)现在,我们可以通过多种方式控制视频,以打开文件wp-custom-header.js
中的声音,然后搜索并删除行e.target.mute();
(在wordpress 4.9.8中为行390)
之前
handler.player = new YT.Player( video, {
height: this.settings.height,
width: this.settings.width,
videoId: this.settings.videoUrl.match( VIDEO_ID_REGEX )[1],
events: {
onReady: function( e ) {
e.target.mute();
handler.showControls();
}, ...
之后
handler.player = new YT.Player( video, {
height: this.settings.height,
width: this.settings.width,
videoId: this.settings.videoUrl.match( VIDEO_ID_REGEX )[1],
events: {
onReady: function( e ) {
// e.target.mute();
handler.showControls();
}, ...
存在许多其他标头的视频功能,而您在此文件中无法自定义。
享受!