title: Facebook Like and Comment Code Script
body: <p>I needed to get a unique url for each page and adapted a script that I found through the help of other members here.</p>
  
  <p>One is for the like button and the other is for the comment box. Is there a more elegant way to do this without so much code?</p>
  
  <pre><code>&lt;br&gt;
  
  &lt;!-- start facebook like code--&gt;
  &lt;div id="thelike"&gt;&lt;/div&gt;
  &lt;script&gt;
  var thisurl = document.URL;
  function changeCommentsUrl(newUrl){
  // should refresh fb like plugin for the "newUrl" variable
  document.getElementById('thelike').innerHTML='';
  parser=document.getElementById('thelike');
  parser.innerHTML='&lt;div class="fb-like" data-href="'+newUrl+'" data-send="true" data-layout="button_count" data-width="400" data-show-faces="false"&gt;&lt;/div&gt;';
  FB.XFBML.parse(parser);
  }
  changeCommentsUrl(thisurl);
  &lt;/script&gt;
  &lt;!-- end facebook like code--&gt;
  
  &lt;br&gt;
  
  &lt;!-- start facebook comment code--&gt;
  &lt;div id="thecomments"&gt;&lt;/div&gt;
  &lt;script&gt;
  var thisurl = document.URL;
  function changeCommentsUrl(newUrl){
  // should refresh fb comments plugin for the "newUrl" variable
  document.getElementById('thecomments').innerHTML='';
  parser=document.getElementById('thecomments');
  parser.innerHTML='&lt;div class="fb-comments" data-href="'+newUrl+'" data-num-posts="10" data-width="400"&gt;&lt;/div&gt;';
  FB.XFBML.parse(parser);
  }
  changeCommentsUrl(thisurl);
  &lt;/script&gt;
  &lt;!-- end facebook coment code--&gt;
  
  &lt;br&gt;
  </code></pre>