Facebook Like Button (again)

I am having a problem similar to:

But when I view source on the page, that Javascript code I created never appears in the body or anywhere in the page.
I am using x-pro-child, would that make a difference on where I pasted the _header.php file?

I pasted the Javascript code at the bottom of the _header.php file. Is that the correct spot?

The site is: http://kimballspub.com/testsite/events/

If you need more info, let me know.

Side note: I tried pasting the javascript at the top of my page in a content area element and the facebook like button works, but only on mobile sites.

I also tried to copy and paste my _header.php file here for inspection, but no matter how I copy it in (blockquote or preformatted text) it hides itself. :man_facepalming:

Hi There,

Thank you for writing in, I think that user you quote above is following my instruction here.

I just tested that method and it still works, please redo what you did but this time follow the instruction thoroughly.

If you read my second reply on that thread, adding the FB SDK code on the _header.php will not work, since you have a Custom Header.

Add your FB SDK code (step 1) on the child theme’s functions.php file instead.

e.g.

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

<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 = 'https://connect.facebook.net/en_US/sdk.js#xfbml=1&version=v3.0';
  fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>

<?php }

Then add the HTML code (step 2) in your page using a RAW Content element.

Hope that shed some lights,
Cheers!

Thank you for the info. Adding to the child’s theme functions works, but for some reason the html code only seems to work on mobile (iPhone). I do not see anything on the desktop version.

Hi There @mattkutz

I have tested your referenced link and I can see those buttons appearing on your Raw content element (see secure note).

Could you please try clearing your browser cache and re-test this issue again.

Hope that helps.
Thanks!

:man_facepalming:
Just needed to clear my cache. I should have thought of that.
Thanks!

Glad that you have managed to fix the issue :slight_smile:

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.