我使用的是定制版的\\u主题,其中我有产品CPT。
在以下文件中,我需要使用无限滚动(由Jetpack提供)-
归档产品。php分类法-[税务名称]。php主页。php存档。php
现在,问题是大多数模板都使用自定义循环(使用WP\\u Query,它以while()之后的分页结束)。
我在函数中使用了以下代码。激活jetpack和光子模块后的php-
function vg_infinite_scroll_init() {
    add_theme_support( \'infinite-scroll\', array(
        \'container\' => \'page-content\',
        \'footer\' => \'page\',
        \'type\'   => \'click\',
        \'render\'  => false,
    ) );
}
add_action( \'after_setup_theme\', \'vg_infinite_scroll_init\' );
 而且,我把所有帖子都包在下面
#page-content 在…上
archive-products.php. 但无限滚动在滚动或单击类型中均不起作用。有什么想法吗?
还向我指出,我应该使用render 无限循环的arg来描述我的自定义循环,但不确定如何做到这一点,因为它在每个模板中都会有所不同。
For Ex: 下面是我在中使用的全部代码archive-products.php - 
<div class="row">
    <?php
    $prod_arch_args = array(
                    \'post_type\' => \'products\',
                    \'posts_per_page\' => \'12\',
                    \'paged\' => get_query_var( \'paged\' ),
                    );
    $prod_arch_query = new WP_Query( $prod_arch_args );
    if( $prod_arch_query->have_posts() ) {
        while( $prod_arch_query->have_posts() ) {
            $prod_arch_query->the_post();
            $prod_images = get_post_meta( $post->ID, \'cmb2_prod_images\', true );
            $prod_price = get_post_meta( $post->ID, \'cmb2_prod_price\', true );
    ?>
            <div class="col-xs-12 col-sm-6 col-md-4 product-main wow fadeInUp">
                <figure itemscope itemtype="http://schema.org/Product" class="product-item relative">
                    <div class="product-display">
                        <div class="list-pic">
                            <a href="<?php the_permalink(); ?>">
                                <?php
                                foreach ($prod_images as $key => $value) {
                                    ?>
                                    <?php echo wp_get_attachment_image( $key, \'prod-list\', \'itemprop = image\' ); ?>
                                    <?php
                                    continue;
                                }
                                ?>
                            </a>
                        </div>
                        <div class="view-detail"><a href="<?php the_permalink(); ?>">View Detail</a></div>
                    </div>
                    <figcaption class="relative">
                        <div class="pro-list-title" >
                            <h3 itemprop="name">
                            <a href="#"><?php the_title(); ?></a>
                            </h3>
                        </div>
                        <div itemprop="offers" itemscope itemtype="http://schema.org/Offer" class="pro-list-rates">
                            <div class="pro-list-rates-new">
                                <span  itemprop="priceCurrency">
                                    <i class="fa fa-inr"></i>
                                </span> 
                                <span itemprop="price"><?php echo $prod_price; ?></span>
                            </div>
                        </div>
                        <div class="add-container">
                            <!-- <a class="btn btn-1 btn-1a">
                                <i class="fa fa-cart-plus"></i> Add to container</a> -->
                            <?php vg_after_entry(); ?>
                        </div>
                    </figcaption>
                </figure>
            </div>
            <?php
        }
        the_posts_navigation();
        wp_reset_postdata();
    }
    ?>
</div>