J
J
Justin Bieber2018-11-14 08:29:30
Facebook
Justin Bieber, 2018-11-14 08:29:30

How to use comments from Facebook on a news site?


Facebook comments stopped working on different pages of the news site.
Used like this:

<div class="fb-comments" data-href="" data-numposts="5"></div>

<script>
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();
  }
} );
</script>

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question