Tagged: Facebook SDK for JavaScript
-
AuthorPosts
-
June 27, 2015 at 11:57 am #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>June 27, 2015 at 12:48 pm #465230Hey!
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!
JosueJune 28, 2015 at 3:05 am #465411Thanks, 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,
PatrickJune 28, 2015 at 1:02 pm #465520Hi Patrick,
Can you please create us a WordPress administrator account? post it here as a private reply.
Regards,
Josue -
AuthorPosts
- You must be logged in to reply to this topic.
