Skip to content

Instantly share code, notes, and snippets.

@rdallaire
Created October 23, 2012 22:22
Show Gist options
  • Save rdallaire/3942061 to your computer and use it in GitHub Desktop.
Save rdallaire/3942061 to your computer and use it in GitHub Desktop.
Facebook Comments on WordPress
<!--
This can go in the comments template or in the single post template where you want the comments to appear
-->
<?php if (comments_open()) { ?><!-- check to see if comments are allow on post -->
<h3 class="comment-count" id="respond">
<!-- Shows amount of comments above -->
<div class="fb-comments-count" data-href="<?php the_permalink(); ?>">0</div> Comments
</h3>
<div id="fb-comment-box">
<div class="fb-comments" data-href="<?php the_permalink(); ?>" data-width="660"></div> <!-- Change data-width to the width you want the form -->
</div>
<?php } else { ?> <!-- if comments are disabled for the post -->
<p>Comments are closed</p>
<?php }; ?>
<!-- ==========================================================================================
Place this at the end of the document before the closing body tag </body>
-->
<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/all.js#xfbml=1";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment