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

comments

Bill Erickson

Bill Erickson is a freelance WordPress developer and a contributing developer to the Genesis framework. For the past 14 years he has worked with attorneys, publishers, corporations, and non-profits, building custom websites tailored to their needs and goals.

Ready to upgrade your website?

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

Let's Talk