Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #465221

    How can I add this snippet to my website.
    Please see below JavaScript from Facebook.

    The following snippet of code will give the basic version of the SDK where the options are set to their most common defaults.
    You should insert it directly after the opening <body> tag on each page you want to load it:

    <script>
    window.fbAsyncInit = function() {
    FB.init({
    appId : ‘XXXXXXXXXXXXXXX’,
    xfbml : true,
    version : ‘v2.3’
    });
    };

    (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/en_US/sdk.js”;
    fjs.parentNode.insertBefore(js, fjs);
    }(document, ‘script’, ‘facebook-jssdk’));
    </script>

    #465230

    Hey!

    Try adding this at the very end of your theme / child theme functions.php file:

    add_action('wp_footer', function() {
    ?>
    <script>
    window.fbAsyncInit = function() {
    FB.init({
    appId : ‘XXXXXXXXXXXXXXX’,
    xfbml : true,
    version : ‘v2.3′
    });
    };
    
    (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/en_US/sdk.js”;
    fjs.parentNode.insertBefore(js, fjs);
    }(document, ‘script’, ‘facebook-jssdk’));
    </script>
    <?php	
    });

    Cheers!
    Josue

    #465411

    Thanks, Josue.
    I didn’t work. Please see the error message below.

    Parse error: syntax error, unexpected ‘(‘, expecting T_STRING or T_VARIABLE or ‘$’ in /home/patrickp/public_html/iincomeplus.com.au/wp-content/themes/enfold-child/functions.php on line 19

    I had to remove it from functions.php to be able to access my website again.

    Kind regards,
    Patrick

    #465520

    Hi Patrick,

    Can you please create us a WordPress administrator account? post it here as a private reply.

    Regards,
    Josue

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.