wordpress ajax分页在10页后中断
有人能帮我做ajax分页吗?我已经做了两天了,还没弄明白。我加载了更多样式的分页,这是代码,preety classic(下面)。 除非占位符到达第10页,否则所有内容都可以作为规划工作。然后,地狱挣脱了,再也没有装载任何东西了。该按钮在到达maxpages之前仍然有效,因此该按钮被删除,但超过10个占位符时不会发生任何事情。我目前正在使用此脚本的网站,您可以测试自己的地方如下: 我希望有人能对我说的有个想法。提前谢谢wordpress ajax分页在10页后中断,ajax,wordpress,pagination,Ajax,Wordpress,Pagination,有人能帮我做ajax分页吗?我已经做了两天了,还没弄明白。我加载了更多样式的分页,这是代码,preety classic(下面)。 除非占位符到达第10页,否则所有内容都可以作为规划工作。然后,地狱挣脱了,再也没有装载任何东西了。该按钮在到达maxpages之前仍然有效,因此该按钮被删除,但超过10个占位符时不会发生任何事情。我目前正在使用此脚本的网站,您可以测试自己的地方如下: 我希望有人能对我说的有个想法。提前谢谢 jQuery(document).ready(function() {
jQuery(document).ready(function() {
// The number of the next page to load (/page/x/).
var pageNum = parseInt(pbd_alp.startPage);
// The maximum number of pages the current query can return.
var max = parseInt(pbd_alp.maxPages);
// The link of the next page of posts.
var nextLink = pbd_alp.nextLink; pageNum++;
//Load more videos translation
var more = pbd_alp.more;
//Loading videos translation
var loading = pbd_alp.loading;
/**
* Replace the traditional navigation with our own,
* but only if there is at least one page of new posts to load.
*/
if(pageNum <= max) {
// Remove the traditional navigation.
jQuery('.pagination').remove();
// Insert the "More Posts" link.
if( jQuery('#content').find('ul.listing-videos').length == 1 ){
jQuery('#content ul.listing-videos').append('<li class="more-posts pbd-alp-placeholder-' + pageNum + '"></li>');
jQuery('#content').append('<p id="pbd-alp-load-posts" class="pagination"><a href="#">' + more + '</a></p>');
}
}
/**
* Load new posts when the link is clicked.
*/
jQuery('#pbd-alp-load-posts a').click(function() {
// Are there more posts to load?
if(pageNum <= max) {
// Show that we're working.
jQuery(this).text(loading);
jQuery('.pbd-alp-placeholder-'+ pageNum).load(nextLink + ' #content ul.listing-videos li',
function() {
//jQuery('.pbd-alp-placeholder-'+ pageNum).children('li').unwrap();
console.log(pageNum);
jQuery(this).children().hide();
$newContent = jQuery(this).children().unwrap();
$newContent.fadeIn('fast');
// Update page number and nextLink.
pageNum++;
nextLink = nextLink.replace(/\/page\/[0-9]?/, '/page/'+ pageNum);
**// Add a new placeholder, for when user clicks again.
jQuery('#content ul.listing-videos').append('<li class="more-posts pbd-alp-placeholder-'+ pageNum +'"></li>');**
// Update the button message.
if(pageNum <= max) {
jQuery('#pbd-alp-load-posts a').text('Vezi mai multe');
} else {
jQuery('#pbd-alp-load-posts a').remove();
}
}
);
} else {
jQuery('#pbd-alp-load-posts a').append('.');
}
return false;
});
});
jQuery(文档).ready(函数(){
//要加载的下一页的编号(/page/x/)。
var pageNum=parseInt(pbd_alp.起始页);
//当前查询可以返回的最大页数。
var max=parseInt(pbd_alp.maxPages);
//下一页文章的链接。
var nextLink=pbd_alp.nextLink;pageNum++;
//加载更多视频翻译
var more=pbd_alp.more;
//加载视频翻译
var荷载=pbd_alp.荷载;
/**
*用我们自己的导航取代传统的导航,
*但前提是至少要加载一页新帖子。
*/
如果(pageNum用于wordpress中的ajax分页,您可以使用类似的插件
或
jQuery(函数($){
$('#content')。在('单击','分页a',函数(e){
e、 预防默认值();
var link=$(this.attr('href');
$(“#内容”).fadeOut(500,function(){
$(this).load(link+'#content',function()){
美元。法代因(500);
});
});
});
});
我也有同样的问题。
如果仍然发生,请更换:
nextLink = nextLink.replace(/\/page\/[0-9]?/, '/page/'+ pageNum);
到
错误的正则表达式[0-9]出现问题?只匹配从1到9的单个数字。从10开始只需要1。相反,[0-9]*匹配从0到无穷大。因此,它在9之后中断(从0到9),因为下一个10,它只需使用1。这一个是主题的一部分,我正在尽可能地与插件保持距离。@VartolomeiEduardClaudiu根据您的上述评论更改代码。我不想粗鲁,完全更改代码,我可以随时更改,但随后我必须为主题重新制作所有css,这是一种痛苦。我现在的工作效率是99%,问题是当你到达plaheholder 10,11,12时,它不再显示任何内容。我留下了一个url,以便你可以测试我说的内容。我真的不想重写代码。虽然这不是我想要的,但谢谢你的回答。答案是什么?很难说。
nextLink = nextLink.replace(/\/page\/[0-9]?/, '/page/'+ pageNum);
nextLink = nextLink.replace(/\/page\/[0-9]*/, '/page/'+ pageNum);