WordPress如何实现ajax无刷新筛选加载分类文章?wordpress实现在首页通过ajax无刷新的方式筛选加载分类文章;效果如下:

JS代码

jQuery(\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’.cat-nav > li > a\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’).on(\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’click\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’,function(){

var next_url = jQuery(this).attr(\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\”href\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\”);

jQuery(\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’.cat-nav > li\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’).removeClass(\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’current-menu-item\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’);

jQuery(this).parent().addClass(\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’current-menu-item\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’);

jQuery.ajax({

type: \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’get\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’,

url: next_url + \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’#posts\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’,

success: function(data){

posts = jQuery(data).find(\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\”#posts .post\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\”);

if (next_url.indexOf(\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\”page\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\”) < 1) {

jQuery(\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\”#posts\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\”).html(\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’);

}

jQuery(\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\”#posts\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\”).append(posts.fadeIn(100));

}

});

return false;

});

添加到要显示ajax筛选分类的地方

相关新闻

发表评论

您的电子邮箱地址不会被公开。 必填项已用*标注

联系我们

联系我们

151-1101-0018

在线咨询:
邮件:30115776@qq.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信
关注微信
分享本页
返回顶部