admin管理员组文章数量:1432196
I'm trying to embed a Facebook video in my site using the snippets generated by the Facebook Embedded videos page.
Having done so, I add this function to a custom, site specific plugin so as to load the FB javascript API:
add_action('wp_head', 'js_sdk_wp_head');
function js_sdk_wp_head(){
?>
<div id="fb-root"></div>
<script async defer crossorigin="anonymous" src=".js#xfbml=1&version=v3.3"></script>
<?php
}
I then use the code editor to add the following to the page:
<!-- wp:html /-->
<div class="fb-video" data-href="/?v=12345" data-width="500" data-show-text="false">
</div>
And when I do so, nothing happens, (apart from a blank line being inserted into the WP post).
What am I doing wrong?
I'm trying to embed a Facebook video in my site using the snippets generated by the Facebook Embedded videos page.
Having done so, I add this function to a custom, site specific plugin so as to load the FB javascript API:
add_action('wp_head', 'js_sdk_wp_head');
function js_sdk_wp_head(){
?>
<div id="fb-root"></div>
<script async defer crossorigin="anonymous" src="https://connect.facebook/en_GB/sdk.js#xfbml=1&version=v3.3"></script>
<?php
}
I then use the code editor to add the following to the page:
<!-- wp:html /-->
<div class="fb-video" data-href="https://www.facebook/watch/?v=12345" data-width="500" data-show-text="false">
</div>
And when I do so, nothing happens, (apart from a blank line being inserted into the WP post).
What am I doing wrong?
Share Improve this question asked May 11, 2019 at 14:06 lovelyzoolovelyzoo 31 bronze badge1 Answer
Reset to default 0It worked correctly for me, however I used the wp_enqueue_scripts hook to add the JavaScript.
function mytheme_enqueue_scripts() {
wp_register_script('facebook-video', 'https://connect.facebook/en_GB/sdk.js#xfbml=1&version=v3.3', '', '');
wp_enqueue_script('facebook-video');
}
add_action('wp_enqueue_scripts', 'mytheme_enqueue_scripts');
- Do you see any errors in your browser console or network tab?
- Do you see the JS added to your page if you inspect?
本文标签: How to (correctly) embed a Facebook video
版权声明:本文标题:How to (correctly) embed a Facebook video? 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745502918a2661112.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论