简体   繁体   English

删除或自定义woocommerce特定产品类别的下拉排序菜单

[英]Removing or customizing drop-down sorting menu for woocommerce for specific product-category

I would like to either remove the product sorting or customize the sorting options for one specific product-category while not effecting the sorting for all other pages/categories on my site. 我想删除产品排序或为一种特定的产品类别自定义排序选项,同时不影响网站上所有其他页面/类别的排序。

I found this question ; 我发现这个问题 ; I have added the code to the functions.php, but I am not sure what to do next. 我已经将代码添加到functions.php中,但是我不确定下一步该怎么做。

I would like to either remove the " Sort by Price " and have only " Sort by AZ " and " Sort by ZA " or remove the sorting altogether. 我想删除“ 按价格排序 ”,而只有“ 按AZ排序 ”和“ 按ZA排序 ”,或者完全删除排序。

Let's say product category's name is " BrandABC ". 假设产品类别的名称为“ BrandABC ”。 So on my site the url would appear as follows: 因此,在我的网站上,URL如下所示:
http://www.mywebsite.com/product-category/brandABC/ http://www.mywebsite.com/product-category/brandABC/

I found out that page has the following while editing the product-category: 我在编辑产品类别时发现该页面具有以下内容:

taxonomy=product_cat&tag_ID=13&post_type=product......

I've tried putting this in the custom CSS of my theme: 我尝试将其放在主题的自定义CSS中:

.product_cat .id-13 .woocommerce-ordering {
    display: none;
}

also tried: 还尝试了:

.product_cat&tag_ID=13 .woocommerce-ordering {
    display: none;
}

Neither worked. 两者都不起作用。 How would I identify and target just the BrandABC page? 我如何仅识别和定位BrandABC页面?

In Product Category Archive page WooCommerce adds dynamic class in body tag like term-your-cat-slug and term-your-term-ID . 在“产品类别存档”页面中,WooCommerce在body标签(例如term-your-cat-slugterm-your-term-ID添加了动态类。

For Example if your product category name is: Example Category and it slug is example-category and term ID is 10 ; 例如,如果您的产品类别名称是: Example Category,并且它的子级是example-category ,术语ID是10 then WooCommerce will add following class in body tag 然后WooCommerce将在body标签中添加以下类

term-example-category term-10

So you can add any of the following CSS code to your active theme style.css or child theme style.css 因此,您可以将以下任意CSS代码添加到活动主题style.css或子主题style.css中

.term-brandabc .woocommerce-ordering{
    display: none;
}

Alternative CSS (Recommended): 替代CSS(推荐):

.term-13 .woocommerce-ordering{
    display: none;
}

Hope this helps! 希望这可以帮助!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM