I am using load more with ajax for my portfolios and it’s working well but I’m having a problem when I am making the portfolio as a front page, the load more isn’t working anymore, it displays same posts
This is the code of load more in js
var isoElem = jQuery('.masonry-images');
if(isoElem.length > 0) {
var elem = isoElem[0];
var iso = new Isotope( elem, {
itemSelector: '.work-image',
});
}
var page = 1;
var loadMorePosts = jQuery('#load-more-posts').text();
function loadMore() {
page++;
jQuery.ajax({
type: "GET",
url: './page/' + page,
beforeSend: function () {
jQuery('#load-more-posts').html("<i class='fa fa-spinner fa-spin'></i>");
},
complete: function () {
},
success: function (data) {
var $data = jQuery(data).find('.single-blog,.work-image');
if ($data.length > 0) {
jQuery('#load-more-posts').html(loadMorePosts);
jQuery('#blog-posts,#portfolio-posts').append($data);
if(isoElem.length > 0) {
iso.appended($data);
}
$data.css("display", "none");
$data.fadeIn("slow");
}
else {
jQuery('#load-more-posts').html('No More Posts');
}
},
error: function () {
jQuery('#load-more-posts').html('No More Posts');
}
});
}
jQuery('#load-more-posts').click(function(e) {
e.preventDefault();
loadMore();
});
You can try here live at ‘ http://illyrianthemes.com/themes/vicenza/ ‘ here is not working when I remove as front page of WordPress then works perfectly for example check four columns ‘ http://illyrianthemes.com/themes/vicenza/four-columns/ ‘.
Best Regards
After a long research I found the answer if someone needs it.
Instead of doing this:
do this:
Maybe it will help someone.