我想在博客页面上创建ajax分页.. 我需要做的是最初显示5个帖子,然后点击“加载更多帖子”链接时再加载5个帖子。用Ajax在wordpress中“加载更多帖子”
下面是我使用的JavaScript:
<script>
jQuery(document).ready(function() {
// ajax pagination
jQuery('.nextPage a').live('click', function() {
// if not using wp_pagination, change this to correct ID
var link = jQuery(this).attr('href');
// #main is the ID of the outer div wrapping your posts
jQuery('.blogPostsWrapper').html('<div><h2>Loading...</h2></div>');
// #entries is the ID of the inner div wrapping your posts
jQuery('.blogPostsWrapper').load(link+' .post')
});
}); // end ready function
</script>
的问题是,当我点击老职位获得通过更换新的链接,我需要证明的旧帖子以及新帖...
这里是更新的jQuery代码,它启用ajax分页。现在
jQuery(document).ready(function(){
jQuery('.nextPage a').live('click', function(e){
e.preventDefault();
var link = jQuery(this).attr('href');
jQuery('.blogPostsWrapper').html('Loading...');
jQuery('.blogPostsWrapper').load(link+' .post');
});
});
唯一的问题是旧的帖子得到消除,我需要保持新老帖..
我知道你已经发布了一段时间了,但我想看看这个xhtml。 – bsoist