<script> tags aren’t working in WordPress

All,
I have some script tags that are not working in WordPress. If I have the following code:

<script type="text/javascript">
  window.fbAsyncInit = function() {
    FB.init({
      appId      : '<?= 1234?>',
      status     : true, 
      cookie     : true,
      xfbml      : true,
      oauth      : true,
    });

    FB.Event.subscribe('auth.login', function(response) {
      window.location.reload();
    });
  };

  (function(d){
     var js, id = 'facebook-jssdk'; if (d.getElementById(id)) {return;}
     js = d.createElement('script'); js.id = id; js.async = true;
     js.src = "//connect.facebook.net/en_US/all.js";
     d.getElementsByTagName('head')[0].appendChild(js);
   }(document));
</script>

When I preview this in my browser it looks like this:

Read More
<script type="text/javascript">
  window.fbAsyncInit = function() {
    FB.init({
      appId      : '123',
      status     : true, 
      cookie     : true,
      xfbml      : true,
      oauth      : true,
    });</p>
<p>        FB.Event.subscribe('auth.login', function(response) {
      window.location.reload();
    });
  };</p>
<p>      (function(d){
     var js, id = 'facebook-jssdk'; if (d.getElementById(id)) {return;}
     js = d.createElement('script'); js.id = id; js.async = true;
     js.src = "//connect.facebook.net/en_US/all.js";
     d.getElementsByTagName('head')[0].appendChild(js);
   }(document));
</script>

Which I believe is causing the program not to execute what is in the script tags. How can I prevent this from happening?

Related posts

Leave a Reply

2 comments