Hi, I am trying to install some FB plugins on my site and there is a code I need to insert right after the opening <body> tag so it gets loaded for every page on my website. The question is, where do I have to paste this code?:
<div id="fb-root"></div>
<script>(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/nl_NL/sdk.js#xfbml=1&version=v2.3&appId=415746658610664";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>
Thanks, Eric.
Hi EricSmeets!
You could try this in functions.php to see if it works for you:
function add_custom_code(){
?>
<div id="fb-root"></div>
<script>(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/nl_NL/sdk.js#xfbml=1&version=v2.3&appId=415746658610664";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>
<?php
}
add_action('wp_head', 'add_custom_code');
Cheers!
Rikard
Hello Rikard,
Perfect!
Thanks!