Facebook Comments Code

Featured in: Adding Facebook Comments

<?php
/**
* Facebook Comments
*
*/
function be_facebook_comments() {
echo '<h2>Submit a Comment</h2>';
echo '<div class="fb-comments" data-href="' . be_production_url( 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' );
/**
* Facebook Comment Moderators
* Use this to find your ID: http://findmyfbid.com/
*/
function be_facebook_comment_moderators() {
echo '<meta property="fb:admins" content="12345678"/>';
}
add_action( 'wp_head', 'be_facebook_comment_moderators' );
/**
* Production URL
* Helper function to always reference live URLs
*/
function be_production_url( $url ) {
$production_url = 'https://clientsite.com';
$dev_urls = array(
'http://localdev/clientsite',
'http://clientsite.staging.wpengine.com',
);
return str_replace( $dev_urls, $production_url, $url );
}
view raw single.php hosted with ❤ by GitHub

Bill Erickson

Bill Erickson is the co-founder and lead developer at CultivateWP, a WordPress agency focusing on high performance sites for web publishers.

About Me
Ready to upgrade your website?

I build custom WordPress websites that look great and are easy to manage.

Let's Talk