1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Issue trying to get Facebook SDK to work in Wordpress template file

Discussion in 'WordPress' started by Boxwell, Jul 5, 2017.

  1. #1
    Hello,
    I'm creating a custom template file for my Avada child theme. I'm using the Facebook SDK and would eventually like to create a box where people can send messages straight through to Facebook.

    I have created the following custom template file:
    <?php
    /*
    Template Name: Isary Contact Page
    */
    ?>
    
    <?php get_header();
    
    ?>
    
     
    <script>
      window.fbAsyncInit = function() {
        FB.init({
          appId      : '1366583986735816',
          xfbml      : true,
          version    : 'v2.9'
        });
        FB.AppEvents.logPageView();
      };
    
      (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>
    
    <div
      class="fb-like"
      data-share="true"
      data-width="450"
      data-show-faces="true">
    </div>
    
    <?php do_action( 'avada_after_content' ); ?>
    <?php get_footer();
    
    Code (markup):
    When I do this, I get the following error in Console:
    If I remove the get_header() section, part of the Avada theme wont load, and I get the following error:
    I've been scratching my head at this for the last few hours. Any help is greatly appreciated.

    Best wishes,

    Graeme
     
    Boxwell, Jul 5, 2017 IP