it's duplicating some questions , here is the my code ; if I can do this i will share my theme here free
$(function(){
var $container = $('#container');
$container.imagesLoaded(function(){
$container.masonry({
itemSelector : '.box',
isFitWidth: true,
columnWidth: 236,
gutter: 14
});
$('#loading').hide();
});
$container.infinitescroll({
navSelector : '.qa-page-links-list', // selector for the paged navigation
nextSelector : '.qa-page-links-list .qa-page-next', // selector for the NEXT link (to page 2)
itemSelector : '.box' // selector for all items you'll retrieve
},
// trigger Masonry as a callback
function( newElements ) {
// hide new items while they are loading
var $newElems = $( newElements ).css({ opacity: 0 });
// ensure that images load before adding to masonry layout
$newElems.imagesLoaded(function(){
// show elems now they're ready
$newElems.animate({ opacity: 1 });
$container.masonry( 'appended', $newElems, true );
});
}
);
});