更改 WooCommerce 'xyz' 类别页面上显示的产品数量 [英] Change the Number of Products that Display on WooCommerce 'xyz' category page

查看:27
本文介绍了更改 WooCommerce 'xyz' 类别页面上显示的产品数量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前在xyz"类别中有 19 个项目,但我一次只能看到其中的 5 个并显示分页我不想分页.

I have 19 items in the "xyz" category currently but I am only able to see 5 of them at a time and shows pagination I don't want pagination.

有没有办法让超过 5 个项目出现在您的 xyz 类别的第一页上?

Is there a way to make it to where more than 5 items show up on your first page of your xyz category ?

我在模板的function.php中添加了以下代码

i added following code to my function.php of template

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

但仍显示 5 个产品.

but still its displaying 5 products .

推荐答案

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

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') );

这篇关于更改 WooCommerce 'xyz' 类别页面上显示的产品数量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆