Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #453819

    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.

    • This topic was modified 8 years, 11 months ago by EricSmeets.
    #454266

    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

    #454321

    Hello Rikard,

    Perfect!

    Thanks!

Viewing 3 posts - 1 through 3 (of 3 total)
  • The topic ‘Inserting right after the opening tag’ is closed to new replies.