【问题标题】:Change displayed number of products WooCommerce shop issue更改显示的产品数量 WooCommerce 商店问题
【发布时间】:2021-05-09 19:24:03
【问题描述】:

你好,我把function.php改成了

/**
 * Change number of products that are displayed per page (shop page)
 */
add_filter( 'loop_shop_per_page', 'new_loop_shop_per_page', 20 );

function new_loop_shop_per_page( $cols ) {
  // $cols contains the current number of products per page based on the value stored on Options –> Reading
  // Return the number of products you wanna show per page.
  $cols = 9;
  return $cols;
}

现在我的商店没有在商店页面中显示商品商店 现在我想恢复默认值,我删除了我的 function.php 中的行,但仍然无法正常工作。我必须添加哪个过滤器才能返回?

【问题讨论】:

  • 只需从活动主题的 functions.php 文件中删除代码并保存。如果启用,请清空您的站点缓存。否则,在您的站点上恢复数据库备份。
  • @LoicTheAztec 我这样做了,但仍然什么也看不到:(
  • @LoicTheAztec 现在我可以再次看到它,但是这段代码不起作用它是缓存的东西

标签: php wordpress woocommerce wordpress-theming website-homepage


【解决方案1】:

你可以试试这个

/**
  * WC: change products per page
  * @return int
  */
function so22835795_loop_shop_per_page() {
    return -1; //return any number, -1 === show all
};
add_filter('loop_shop_per_page', 'so22835795_loop_shop_per_page', 10, 0);

【讨论】:

    猜你喜欢
    • 2020-11-26
    • 2019-08-26
    • 2014-01-26
    • 2017-06-24
    • 1970-01-01
    • 1970-01-01
    • 2019-03-05
    • 1970-01-01
    • 2018-09-29
    相关资源
    最近更新 更多