Put below code after 此操作<?php do_action(\'woocommerce_after_shop_loop\' ); ?>
在里面archive-product.php
文件
For Category Products Page
<?php
$cat_data = get_queried_object();
$cat_id = $cat_data->term_id;
if(is_product_category() && !isset($_GET[\'showall\'])){ ?>
<a href="<?php echo get_term_link( $cat_id, \'product_cat\' ) . "?showall=1"; ?>">Show all</a>
<?php } ?>
For Shop Page
<?php if(is_shop() && !isset($_GET[\'showall\'])){ ?>
<a href="<?php echo get_permalink( woocommerce_get_page_id( \'shop\' ) ) . "?showall=1"; ?>">Show all</a>
<?php } ?>
只需将条件检查添加到
functions.php
文件
if(isset( $_GET[\'showall\']) ){
add_filter( \'loop_shop_per_page\', create_function( \'$cols\', \'return -1;\' ) );
} else {
$default_posts_per_page = get_option( \'posts_per_page\' );
add_filter( \'loop_shop_per_page\', create_function( \'$cols\', \'return \'.$default_posts_per_page.\';\' ) );
}