Woocommerce - [product_categories] 简码 - 如何从列表中排除两个类别?
Woocommerce - [product_categories] shortcode - How do I exclude two categories from the list?
所有类别都使用 [product_categories] 简码显示,照常显示缩略图。我如何定位特定的(目前有两个)类别不显示或隐藏。
我试过将这两个类别放在类别 list
的底部(这样它就不会影响产品循环显示的视觉效果)然后使用 CSS
代码:
.home .woocommerce ul.products li:last-of-type {
display: none;
}
但这只针对最后一个而不是倒数第二个。有没有一种方法可以表达 last-of-type 减一?
我觉得 CSS
可能不是最好的方法,而是使用 wordpress hooks。
欢迎任何意见,谢谢。
您可以使用nth-last-child()
The :nth-last-child(n) selector matches every element that is the nth child, regardless of type, of its parent, counting from the last child.
尝试这样的事情:
.home .woocommerce ul.products li:nth-last-child(-n+2) {
display: none;
}
所有类别都使用 [product_categories] 简码显示,照常显示缩略图。我如何定位特定的(目前有两个)类别不显示或隐藏。
我试过将这两个类别放在类别 list
的底部(这样它就不会影响产品循环显示的视觉效果)然后使用 CSS
代码:
.home .woocommerce ul.products li:last-of-type {
display: none;
}
但这只针对最后一个而不是倒数第二个。有没有一种方法可以表达 last-of-type 减一?
我觉得 CSS
可能不是最好的方法,而是使用 wordpress hooks。
欢迎任何意见,谢谢。
您可以使用nth-last-child()
The :nth-last-child(n) selector matches every element that is the nth child, regardless of type, of its parent, counting from the last child.
尝试这样的事情:
.home .woocommerce ul.products li:nth-last-child(-n+2) {
display: none;
}