Answer the question
In order to leave comments, you need to log in
How to make the back button return to the previous screen with infinite scroll?
Implemented infinite scrolling of posts for this guide . Here is the main code of the script to load posts endlessly on page scroll
jQuery(function($){
$(window).scroll(function(){
var bottomOffset = 2000; // отступ от нижней границы сайта, до которого должен доскроллить пользователь, чтобы подгрузились новые посты
var data = {
'action': 'loadmore',
'query': true_posts,
'page' : current_page
};
if( $(document).scrollTop() > ($(document).height() - bottomOffset) && !$('body').hasClass('loading')){
$.ajax({
url:ajaxurl,
data:data,
type:'POST',
beforeSend: function( xhr){
$('body').addClass('loading');
},
success:function(data){
if( data ) {
$('#true_loadmore').before(data);
$('body').removeClass('loading');
current_page++;
}
}
});
}
});
});
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question