Skip to content

Instantly share code, notes, and snippets.

@mjangda
Last active January 6, 2019 10:40
Show Gist options
  • Save mjangda/4556613 to your computer and use it in GitHub Desktop.
Save mjangda/4556613 to your computer and use it in GitHub Desktop.
Dynamically load Facebook comments on your site (if you already have the FB API running)
jQuery( function( $ ) {
if ( 'undefined' === typeof FB )
return;
if ( $( 'body' ).hasClass( 'single-post' ) || $( 'body' ).hasClass( 'page' ) ) {
var $comments_div = $( '<div/>' );
$comments_div.addClass( 'fb-comments' );
$comments_div.attr( 'data-href', document.location );
$comments_div.appendTo( $( '.primary-content' ) );
FB.XFBML.parse();
}
} );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment