在WooCommerce中完全删除Sort by下拉列表

时间:2018-05-01 14:52:34

标签: woocommerce

我想在我的WooCommerce安装中完全删除Sort by下拉列表。

http://cswpstage.hostworks.net/product-category/memorabilia/signed-photos/

谢谢!

1 个答案:

答案 0 :(得分:1)

这取决于您使用的主题。有两种方法,CSS和PHP。

我在你的主题上看到你已经通过CSS使用

隐藏了它
.sort-param-order, 
.sort-param-sort {
    display: none;
}

如果要使用PHP隐藏它,则需要查找添加它的操作并删除该操作。搜索woocommerce_catalog_ordering通常会返回您要查找的操作。

以下是通过标准WooCommerce删除它的方法:

<?php
/**
 * Remove sorting from WooCommerce.
 */
function thenga_remove_filtering() {
    remove_action( 'woocommerce_before_shop_loop', 'woocommerce_catalog_ordering', 30 );
}
add_action( 'init', 'thenga_remove_filtering' );

以下是如何从Storefront主题中删除它:

<?php
/**
 * Remove sorting from Storefront.
 */
function thenga_remove_filtering() {
   remove_action( 'woocommerce_before_shop_loop', 'woocommerce_catalog_ordering', 10 );
   remove_action( 'woocommerce_after_shop_loop', 'woocommerce_catalog_ordering', 10 );
}
add_action( 'init', 'thenga_remove_filtering' );