如何在WooCommerce安装实例中完全移除Sort by下拉菜单
There are a few reliable ways to completely remove the Sort by dropdown from your WooCommerce category pages. Here are the most common methods:
Method 1: Use a WooCommerce Filter Hook (Recommended)
This method removes the dropdown at the code level, which is the cleanest approach. Add the following code to your child theme's functions.php file, or use a custom code snippets plugin to avoid editing theme files directly:
add_filter( 'woocommerce_catalog_orderby', '__return_empty_array' );
This filter overrides WooCommerce's default orderby options and returns an empty array, so the platform won't render the dropdown at all.
Method 2: Hide with CSS
If you prefer a quick visual fix (note: this doesn't remove the element from the DOM, just hides it from view), add this CSS to your theme's custom CSS section or child theme's style.css:
.woocommerce-ordering { display: none !important; }
To target only specific category pages (like your signed photos category), use the category's unique body class:
.tax-product-category.term-signed-photos .woocommerce-ordering { display: none !important; }
Method 3: Use a Customization Plugin
If you don't want to edit code directly, you can use a plugin like Code Snippets to add the filter hook from Method 1, or a WooCommerce-specific customization plugin that lets you disable the sorting dropdown via a simple settings panel.
Always remember to back up your site before making code changes, and use a child theme to avoid losing modifications when your parent theme updates.
内容的提问来源于stack exchange,提问作者pgilpat

