Skip to content

Instantly share code, notes, and snippets.

@MrJSdev
Last active May 30, 2017 10:59
Show Gist options
  • Save MrJSdev/3c59e010114106a3fe17fd9ca65be33a to your computer and use it in GitHub Desktop.
Save MrJSdev/3c59e010114106a3fe17fd9ca65be33a to your computer and use it in GitHub Desktop.
Full code of Facebook comment Box in Genesis Theme: http://extracatchy.net/add-facebook-comments-in-wordpress/
<?php
/**
* Facebook Comments Box
* @link http://extracatchy.net/add-facebook-comments-in-wordpress/
*/
function extracatchy_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', 'extracatchy_facebook_comments' );
remove_action( 'genesis_after_entry', 'genesis_get_comments_template' );
/**
* Facebook Comment Moderator
*/
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' );
/**
* 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 = "http://connect.facebook.net/en_US/sdk.js#xfbml=1&version=v2.5&appId=123456789123456"; /* change appID to yours */
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>
<?php
}
add_action( 'genesis_before', 'be_facebook_sdk' );
/**
* Facebook for Comment Count
*
* @param int $count
* @param int $post_id
* @return int $count
*/
function ea_facebook_for_comment_count( $count, $post_id ) {
if( ! function_exists( 'ea_share' ) )
return $count;
return ea_share()->core->count( $post_id, 'facebook_comments' );
}
add_filter( 'get_comments_number', 'ea_facebook_for_comment_count', 10, 2 );
@MrJSdev
Copy link
Author

MrJSdev commented Mar 24, 2017

This is the full code of adding facebook comments in your genesis theme. I have build a tutorials based on this code at http://extracatchy.net/add-facebook-comments-in-wordpress/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment