按类别分类的 woocommerce 产品在每个页面上重复前 10 个产品,那么如何显示所有产品?

woocommerce products by category repeated first 10 products on each page so how to display all product?

我为 woocommerce 产品创建了自定义代码,根据所选类别显示前 10 个产品,但在分页的第二页显示相同的 10 个产品,同时在所有页面显示相同的产品,当产品按兰德订购然后结果是正确的但我想要标题的结果所以请给我我的代码如下的解决方案。

<ul class="products">
    <?php $cat_slug=get_queried_object()->slug; ?>
    <?php
    $args = array( 'post_type' => 'product',  'product_cat' => $cat_slug, 'orderby' => 'title' );
    $loop = new WP_Query( $args );
    while ( $loop->have_posts() ) : $loop->the_post(); global $product; ?>

        <li class="product_cust ">   
            <div class="woo_100">
                <div id="woo_c">
                    <a href="<?php echo get_permalink( $loop->post->ID ) ?>" title="<?php echo esc_attr($loop->post->post_title ? $loop->post->post_title : $loop->post->ID); ?>">

                    <?php woocommerce_show_product_sale_flash( $post, $product ); ?>

                        <div class="woo_thumb">
                        <?php if (has_post_thumbnail( $loop->post->ID )) echo get_the_post_thumbnail($loop->post->ID, 'shop_catalog'); else echo '<img src="'.woocommerce_placeholder_img_src().'" alt="Placeholder" width="300px" height="300px" />'; ?>
                        </div>
                    </a>
                </div>

                <div id="woo_d">

                    <div class="woo_desc">
                        <div class="nil_desc">
                            <a href="<?php echo get_permalink( $loop1->post->ID ) ?>" title="<?php echo esc_attr($loop1->post->post_title ? $loop1->post->post_title : $loop1->post->ID); ?>">
                                <h3><?php the_title(); ?></h3>
                            </a>
                            <span class="price"><?php echo $product->get_price_html(); ?></span><br>
                        </div>


                        <div class="nil_cart"><?php woocommerce_template_loop_add_to_cart( $loop1->post, $product ); ?>
                        </div>
                    </div>                                                              
                </div>  
            </div> 
        </li>
    <?php endwhile; ?>
    <?php wp_reset_query(); ?>         
</ul>   

您还没有传递任何变量来对其进行分页。

$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$args = array( 'post_type' => 'product',  'product_cat' => $cat_slug, 'orderby' => 'title', 'paged'=>$paged);

同样在循环之后使用 nav.php 获取分页控制链接。