且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

更改 WooCommerce 'xyz' 类别页面上显示的产品数量

更新时间:2023-11-30 09:31:10

这可以在仪表板上设置"选项卡的阅读设置部分进行更改.

This can be changed in the Reading Settings section of the Settings tab on the dashboard.

选项最多显示博客页面控制可以看到的产品数量.将其更改为 19 将允许显示所有 19 个产品.

The option Blog pages show at most controls how many products can be seen. Changing that to 19 will allow all 19 products to be shown.

编辑

add_filter( 'loop_shop_per_page', create_function( '$cols', 'return 19;' ), 20 );

另一个

在woocommerce/includes/class-wc-query.php页面中~365行有以下内容

In the woocommerce/includes/class-wc-query.php page there is the following on line ~365

$q->set( 'posts_per_page', $q->get( 'posts_per_page' ) ? $q->get( 'posts_per_page' ) : apply_filters( 'loop_shop_per_page', get_option( 'posts_per_page' ) ) );

改为:

$q->set( 'posts_per_page', $q->get( 'posts_per_page' ) ? $q->get( 'posts_per_page' ) : apply_filters( 'loop_shop_per_page', '19') );