doufu8887 2015-07-14 06:58
浏览 74

使用wp-pagenavi插件附加ajax分页,而不是删除旧的并加载新的

I have some custom posts call in my template like this.

<div class="container-fluid featured-task-container-home1 all-latst-cards" id="featured-task-container-home">
 <ul>
   <?php if ( have_posts() ): while ( have_posts() ) : the_post(); ?>
     <li>
        <?php if($post->post_type  == "task"){
          show_all_latest_tasks();
        }?>
    </li>
   <?php 
     endwhile; 
        if(function_exists('wp_pagenavi')):
            wp_pagenavi();
        endif;
    else:
        echo __('No tasks posted.',"TaskerDev");
    endif;
    // Reset Post Data
      wp_reset_postdata();
    ?>
 </ul>
</div>

In the above code i used Wp-PageNavi to show pagination. i used one function in ul which add some more content in my post according to it's type. it is working fine right now as it should be But here i want to show Load more button instead pagination and want this to be append more posts in my ul instead removing the old ones.

For Ajax i used this code

<script type="text/javascript" charset="utf-8">
        jQuery(document).ready(function(){
        jQuery('.wp-pagenavi a').live('click', function(e){
          e.preventDefault();
          var link = jQuery(this).attr('href');
          jQuery('.wp-pagenavi').html('Loading...');
          jQuery('.all-latst-cards').load(link+' .all-latst-cards ul');
        });  
        });
</script>

This script is loading posts on same page but removing old ones which is i don't want.

I tried this WP Ajax load more Plugin but this is not getting all the data from my function show_all_latest_tasks();

I tried with many other articles too but no luck right now.

How can i make my pagination a Load more button and append upcoming (second page posts li's ) below my ul

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 用windows做服务的同志有吗
    • ¥60 求一个简单的网页(标签-安全|关键词-上传)
    • ¥35 lstm时间序列共享单车预测,loss值优化,参数优化算法
    • ¥15 基于卷积神经网络的声纹识别
    • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
    • ¥100 为什么这个恒流源电路不能恒流?
    • ¥15 有偿求跨组件数据流路径图
    • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
    • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
    • ¥15 一直显示正在等待HID—ISP