WordPress在首页上的标题youtube视频中没有声音



我试图在我的主题中使用the_custom_header_markup();在页面顶部创建一个视频循环,就像在基本主题tweety1Seventeen中出现的那样,但我不知道如何打开视频声音。

视频由文件/wp-includes/js/wp-custom-header.js控制

要在主题中自定义它们,您需要覆盖此文件。

  1. 将此文件复制到您的资产,从您的网站的根写入

    cp wp包含/js/wp-custom-header.js wp content/themes/[Your Theme]/assets/js/wp-custom-header.js

  2. [Your Theme]/functions.php中注册新文件,添加此代码

    add_action('wp_enque_scripts','register_header_script'(;

    函数register_header_script(({wp_deregister_script('wp自定义标头'(;wp_register_script('wp-custom-header',get_theme_file_uri('/assets/js/wp-custom-header.js'(,array('jquery masony'(,false,1(;}

  3. 现在我们可以通过多种方式控制视频,打开文件wp-custom-header.js中的声音搜索并删除行e.target.mute();(wordpress 4.9.8中的第390行或wordpress 5.5.1中的第394行(

之前

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.target.mute();
handler.showControls();
}, ...

存在许多其他标头的视频功能,您可以在此文件中自定义这些功能。

享受吧!

最新更新