Try changing your code like this, so that you increment a counter each time you load content, and check that counter hasn't reached a certain value before adding more content.
var cLoaded = 0, iMyLoadLimit = 5;
// Infinite Ajax Scroll configuration
$container.infinitescroll({
navSelector: "div.paginate",
nextSelector: "div.paginate a",
itemSelector: "div.element",
maxPage: 5,
loading: {
finishedMsg: 'Load More',
msgText: " ",
img: 'public/img/ajax-loader.gif',
finished: function(){
alert('finished');
}
}
},
function(newElements) {
if(cLoaded < iMyLoadLimit){
var $newElements = $(newElements).css({opacity: 0});
//remove the first item
$newElements.splice(0, 1);
$container.isotope('appended', $newElements);
}
cLoaded++;
}
});