WooCommerce分页未显示在商店页面中

时间:2020-05-09 18:16:44

标签: php wordpress woocommerce

我已经在我的wordpress中安装了woocommerce并创建了一个名为“商店”的页面,然后将woocommerce设置中的产品页面设置为“商店”页面,现在我目前有10种产品,并且每行仅显示6种产品页,但没有显示分页,因此我可以转到产品的第2页。

这是循环

<?php
            $args = array(
                'post_type' => 'product',
            );

            $loop = new WP_Query( $args );

            if ($loop->have_posts()){
                while ($loop->have_posts()){
                    $loop->the_post();?>
                    <div class="col-lg-3 col-md-3 col-sm-3 product-div" data-aos="fade-up">
                        <?php if( has_term( get_tag_ID('best-seller'), 'product_tag' ) ) {?>
                            <span class="best-seller">Best Selling</span>
                        <?php } ?>
                        <div class="inner-product-div">
                            <?php woocommerce_show_product_sale_flash(); ?>

                            <img src="<?php echo get_the_post_thumbnail_url($loop->post->ID, 'shop_catalog');?>" class="img-responsive" alt="">

                            <div class="block-4-text p-4">
                                <h3><a href="<?php echo get_permalink( $loop->post->ID ) ?>"><?php the_title(); ?></a></h3>
                                <p class="mb-0"><?php the_excerpt() ?></p>
                            </div>
                        </div>
                    </div>

                    <?php
                }
            }
            wp_reset_query();
            ?>

            <div class="row" data-aos="fade-up">
                <div class="col-md-12 text-center">
                    <div class="site-block-27">
                        <?php shoppers_pagination() ?>
                    </div>
                </div>
            </div>

这是shoppers_pagination()函数的定义

if ( !function_exists( 'shoppers_pagination' ) ) {

    function shoppers_pagination() {

        global $wp_query;
        $total = $wp_query->max_num_pages;
        $big = 999999999; // need an unlikely integer
        if( $total > 1 )  {
            if( !$current_page = get_query_var('paged') )
                $current_page = 1;
            if( get_option('permalink_structure') ) {
                $format = 'page/%#%/';
            } else {
                $format = '&paged=%#%';
            }
            echo shoppers_paginate_links(array(
                'base'          => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ),
                'format'        => $format,
                'current'       => max( 1, get_query_var('paged') ),
                'total'         => $total,
                'mid_size'      => 3,
                'type'          => 'list',
                'prev_text'     => '&laquo;',
                'next_text'     => '&raquo;',
            ));
        }
    }

}

我尝试了很多循环,但是没有任何效果,请帮帮我

0 个答案:

没有答案