This has really been bugging me out, any help would be MUCH appreciated. So I have a site where I am using this Facebook Comments plugin to display comments on all posts on the front page. I am also using Jetpack plugin with Infinite Scroll functionality.
My problem is, when Infinite Scroll loads new posts the Facebook Comments plugin is not loaded. I know that when new posts have been added through Infinite Scroll there is a “post-load” event:
( function( $ ) {
$( document.body ).on( 'post-load', function () {
// New posts have been added to the page.
} );
} )( jQuery );
But I’m not experienced enough to know how to work with this and where to put any code. Also, I found the following code that can be used to determine which posts are the newly loaded posts:
jQuery( document ).ready( function( $ ) {
infinite_count = 0;
// Triggers re-layout on infinite scroll
$( document.body ).on( 'post-load', function () {
infinite_count = infinite_count + 1;
var $container = $('#content');
var $selector = $('#infinite-view-' + infinite_count);
var $elements = $selector.find('.hentry');
//Here is where I want to load the facebook comments for the
//new posts, instead of the masonry stuff going on
$elements.hide();
$container.masonry( 'reload' );
$elements.fadeIn();
});
});
But again, I’m a beginner so I’m not sure how this could be utilized to load the Facebook Comments Plugin, and then where to even put that code. Again, I’m thankful for any kind of help.
My wordpress site is omgoal.com
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire