Facebook like button javascript error

i want to implent a facebook box from this page
https://developers.facebook.com/docs/plugins/like-button#step-by-step

i get an error from javascript:
})() } catch( e ) { console.warn(‘Inline script x-footer-custom-scripts failed to run’, e) }

Hi There,

Thank you for writing in, the facebook widget provided you two sets of codes right? The first block is a JavaScript SDK which needs to be put as close as possible on the <body> tag.

To do this first navigate to this directory:
x/framework/legacy/cranium/headers/views/global/ and copy the file _header.php

Then on your child theme navigate to this directory:
x-child/framework/legacy/cranium/headers/views/global/
If this directory does not exist, create it. Then there paste the _header.php file that you just copied.

Then open and edit the copied _header.php file, put the FB JavaScript SDK code just below the line:

<body <?php body_class(); ?>>

After that you can place the second code (actual widget code) wherever you want the like button to appear on your page.

Hope it helps,
Cheers!

Hey thanks

i just set it all new up as you told me. i have the pro theme. but there is the path.

i but the javascript below the body tag.
und i set up new the wiget
deleted all cache

but there is nothing to see.

Hi There,

Yup, that is not going to work if you have a custom header, please add the custom function below on your child theme’s functions.php file instead.

/**
FB JavaScript SDK code
*/
add_action('x_before_site_begin','fb_javaScript_sdk');
function fb_javaScript_sdk () { ?>

<!-- Replace this line with your FB JavaScript SDK code -->

<?php }

Remember to clear all caches before previewing your page, you can check your page if the FB JavaScript SDK code is successfully added by viewing the page source (ctrl+U / Command+Option+U) on your page, if you see the code near the <body> tag then you know you successfully added the code.

Provide us credentials in secure note if this does not work still.

Thanks,

1 Like