Adding Facebook Comments

Facebook Comments can be a great tool to increase the social sharing of posts. When people leave a comment, it will be shared on Facebook. Since most people are already logged into their Facebook accounts, you’re also simplify their commenting experience.

There’s no need to install a plugin – it only takes a few lines of code.

We are replacing the WordPress comment area with the Facebook comments code. My example below shows how to implement it in Genesis, but this can easily be applied to any theme.

<?php
/**
* Facebook Comments
* @link http://www.nepalknow.com/facebook-comments-in-wordpress
*/
function be_facebook_comments() {
echo '<h2>Submit a Comment</h2>';
echo '<div class="fb-comments" data-href="' . get_permalink() . '" data-numposts="5" data-width="100%"></div>';
}
add_action( 'genesis_after_entry', 'be_facebook_comments' );
remove_action( 'genesis_after_entry', 'genesis_get_comments_template' );

You can also specify an admin who can moderate comments by placing a meta tag in the document’s head that contains your Facebook ID (use this site to find your Facebook ID).

Alternatively, you can create a Facebook app and specify your App ID in the document’s head. This lets you have multiple administrators for your site’s comments (all the admins of your Facebook app). You’ll also get access to a moderating interface.

<?php
/**
* Facebook Comment Moderator
* @link http://www.nirmalkhadka.com/facebook-comments-in-wordpress
*/
function be_facebook_comment_moderator() {
// Using your individual facebook ID
echo '<meta property="fb:admins" content="{YOUR_FACEBOOK_USER_ID}" />';
// Or using a Facebook App ID
echo '<meta property="fb:app_id" content="{YOUR_APP_ID}" />';
}
add_action( 'wp_head', 'be_facebook_comment_moderator' );

Displaying the comment count

Now that you’re using Facebook Comments instead of standard WordPress comments ,the WordPress functions for displaying comment count won’t know the actual count. I recommend installing EA Share Count, which collects the share counts across multiple services, including Facebook Comments. Then use the following code to change the WordPress comment count to use the Facebook comments:

<?php
/**
* Add Facebook SDK
*
*/
function be_facebook_sdk() {
?>
<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&version=v2.5&appId=123456789123456";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>
<?php
}
add_action( 'genesis_before', 'be_facebook_sdk' );

 Danish Krone Converter
Nepalese Rupee Exchange Rate