如何从添加自定义脚本this answer 到我的网站阻止自定义视频标题自动播放?
$( document ).ready( function() {
$( document ).on( \'wp-custom-header-video-loaded\', function() {
$("#wp-custom-header-video").attr(\'autoplay\',false);
});
});
如何从添加自定义脚本this answer 到我的网站阻止自定义视频标题自动播放?
$( document ).ready( function() {
$( document ).on( \'wp-custom-header-video-loaded\', function() {
$("#wp-custom-header-video").attr(\'autoplay\',false);
});
});
如果您有自己的主题或子主题,则可以在脚本标记中将其添加到模板中。我建议您在调用<?php wp_footer(); ?>
<script>
jQuery( document ).ready( function() {
jQuery( document ).on( \'wp-custom-header-video-loaded\', function() {
jQuery("#wp-custom-header-video").attr(\'autoplay\',false);
});
});
</script>
注意我已经改变了$
到jQuery
因为WordPress的jQuery默认以无冲突模式安装,并且不定义$
.或者,您可以将其作为插件或主题的内联脚本排队
function wp_custom_header_video_autoplay_false() {
wp_add_inline_script( \'jquery\', "<script>
jQuery( document ).ready( function() {
jQuery( document ).on( \'wp-custom-header-video-loaded\', function() {
jQuery("#wp-custom-header-video").attr(\'autoplay\',false);
});
});
</script>
");
};
add_action( \'wp_enqueue_scripts\', \'wp_custom_header_video_autoplay_false\' );
我使用这段代码学习vuejs,并使用WordPress REST API制作一个公文包无限滚动。我可以呈现前十篇文章,但在滚动时,vue将停止工作,并出现与api提供的特色图像url相关的错误:[Vue warn]:呈现错误:“TypeError:无法读取未定义的属性“wp:featuredmedia”(在根目录中找到)引用错误的代码行是self.posts.push(data);TypeError:无法读取未定义的属性“wp:featuredmedia”这一行表示另一个错误:$.getJSON( \'w