向自定义文章类型添加AJAX分页

向自定义文章类型添加AJAX分页,ajax,wordpress,pagination,Ajax,Wordpress,Pagination,在WordPress中,我使用以下代码按类别显示博客文章列表。有人能帮我在每篇文章中添加AJAX分页吗?因为我只想每页显示6篇文章 function get_cat_posts() { if ( !wp_verify_nonce( $_REQUEST['nonce'], 'mysite-cat-nav')) { exit('No naughty business please'); } $ids = array(

在WordPress中,我使用以下代码按类别显示博客文章列表。有人能帮我在每篇文章中添加AJAX分页吗?因为我只想每页显示6篇文章

   function get_cat_posts() {

       if ( !wp_verify_nonce( $_REQUEST['nonce'], 'mysite-cat-nav')) {
             exit('No naughty business please');
        } 

        $ids = array();
        if( isset($_POST['term_id']) && !empty($_POST['term_id']) ) {

            $term_id = $_POST['term_id'];
            $paged = ( get_query_var('paged') ) ? get_query_var('paged') : 1;
              $args = array(
                'post_type' => 'post',
                'order'     => 'DESC',
                'posts_per_page' => -1,
                'paged'     => $paged,
                'tax_query' => array(
                      array(
                        'taxonomy' => 'category',
                        'field'    => 'term_id',
                        'terms'    => $term_id,
                      ),
                    ),
              );
下面的代码是我在按类别显示帖子时的查询和循环

// The Query
          $the_query = new WP_Query( $args );

          // The Loop
          if ( $the_query->have_posts() ) {
            while ( $the_query->have_posts() ) {
              $the_query->the_post();
                $id = get_the_ID();
                $title = get_the_title();
                $categories = get_the_category();
                $content = wp_trim_words( get_the_content(), 12, '...' );
                $image = get_the_post_thumbnail();

                echo '<div class="col-container col-md-4">
                    <div id="post-'. $id . '" class="col rj-inner-border">
                        <div class="et_pb_image_container">' . $image . '</div>
                        <div class="rj-the-content">
                            <h2 class="rj-post-title">
                                <a href="'.get_the_permalink().'">'.$title.'</a>
                            </h2>
                            <p class="post-meta">';
                                $count = 1;
                                $category_count = count($categories);
                                foreach ($categories as $category) {
                                    $term_link = get_category_link( $category->term_id );

                                    if($count == $category_count){
                                        echo '<a href="' . $term_link .'" rel="category tag">'. $category->name .'</a> ';
                                    }else{
                                        echo '<a href="' . $term_link .'" rel="category tag">'. $category->name .'</a>, ';
                                    }
                                    $count++;
                                }  
                            echo '</p>
                            <div class="post-content" style="height: 89px;">
                                <p>'. $content.'</p>
                            </div>          

                        </div>
                    </div>
                </div>';
            }           

            wp_reset_postdata();
            } else {
        // no posts found
      }

ajax正在工作?你可以检查它的完整代码是的,先生@Rajkumargor,但我的问题是我在每个博客列表中的ajax分页,我不知道如何在它上设置ajax分页。
$(document).on('click', '#menu-menu-blog-categories li.menu-item', function(e) {
        e.preventDefault();
        var term_id = $(this).attr('data-term-id');


        $.ajax({
            url : formaliti.ajax_url,
            type : "POST",
            data : {
                action : 'get_cat_posts',
                nonce : formaliti.nonce,
                term_id : term_id
            },  
            beforeSend : function() {

            },
            success : function(response) {
                $('.fl-node-5b076b128e378').html(response);

            },
            error : function(err) {
                console.log(err);
            }
        });
    });