Navigation
This is archived content. Visit our new forum.
  • Author
    Posts
  • #162227

    dscuba
    Participant

    Hi Team X,

    I’m trying to add Facebook SDK code so I can add a Like button and get Insights for my website. Not sure what file to place these two pieces of code in and where exactly on my backend?

    The first code says “Add this meta property to your root webpage”.

    The second code says:

    Initialize the JavaScript SDK using this app:
    Espressoul Cafe

    Include the JavaScript SDK on your page once, ideally right after the opening <body> tag.

    <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/en_US/sdk.js#xfbml=1&appId=1497708500480712&version=v2.0”;
    fjs.parentNode.insertBefore(js, fjs);
    }(document, ‘script’, ‘facebook-jssdk’));</script>

    #162529

    Paul R
    Moderator

    Hi,

    Thanks for writing in!

    You can use facebook plugin to add it.

    Please see http://www.wpbeginner.com/wp-tutorials/how-to-add-the-facebook-like-box-fan-box-in-wordpress/

    Hope that helps.

    #162984

    dscuba
    Participant

    The FB plugin is no longer supported, has poor reviews recently, and isn’t compatible with the current WP version.
    Any other thoughts or recommendations? See question above as I need to add this code.

    Please consider adding social sharing integration into your next add-on update. Unless you know of another plugin that other X-users are using.

    Thanks

    #163332

    Paul R
    Moderator

    Hi,

    To add the code, you can create _header.php in wp-content\themes\x-child-ethos\framework\views\global
    then copy the code below into that file.(assuming you are using ethos stack)

    
    <?php
    
    // =============================================================================
    // VIEWS/GLOBAL/_HEADER.PHP
    // -----------------------------------------------------------------------------
    // Declares the DOCTYPE for the site and include the <head>.
    // =============================================================================
    
    ?>
    
    <!DOCTYPE html>
    <!--[if IE 9]><html class="no-js ie9" <?php language_attributes(); ?>><![endif]-->
    <!--[if gt IE 9]><!--><html class="no-js" <?php language_attributes(); ?>><!--<![endif]-->
    
    <head>
      <meta charset="<?php bloginfo( 'charset' ); ?>">
      <meta name="viewport" content="width=device-width, initial-scale=1.0">
      <title><?php wp_title(''); ?></title>
      <link rel="profile" href="http://gmpg.org/xfn/11">
      <link rel="pingback" href="<?php bloginfo( 'pingback_url' ); ?>">
      <?php wp_head(); ?>
    </head>
    
    <body <?php body_class(); ?>>
      <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/en_US/sdk.js#xfbml=1&appId=1497708500480712&version=v2.0";
    fjs.parentNode.insertBefore(js, fjs);
    }(document, 'script', 'facebook-jssdk'));</script>
      <?php do_action( 'x_before_site_begin' ); ?>
    
      <div id="top" class="site">
    
      <?php do_action( 'x_after_site_begin' ); ?>
    

    You can then place the code from facebook wherever you want the like box to appear on your page

    Hope that helps.

    #163608

    dscuba
    Participant

    Well, I installed a plugin called “Insert Headers and Footers” since I’m not technically inclined. I put the code in the footer section because it said – “These scripts will be printed above the </body> tag.” The Header section said – “These scripts will be printed in the <head> section.”

    Is this correct?

    Additionally, I just received this message from my host provider who was looking at why my website is so slooow and I’m getting CDN timeout errors.

    1) your facebook plugin when it gets certain requests I couldn’t find what requests but it causes php to crash and have to start back up this will cause current connections to be closed and could cause timeout issues. Here is the error for that:
    PHP Fatal error: Cannot use object of type WP_Error as array in /home2/espresv0/public_html/wp-content/plugins/x-facebook-comments/functions/output.php on line 87

    #163790

    Rad
    Moderator

    Hi there,

    I just replied at your other thread’s with same issue. Please avoid double thread that tackles same issue.

    Thanks!