如何在woocommerce wordpress中隐藏产品类别

时间:2016-01-06 13:06:24

标签: wordpress woocommerce hide product categories

只是想知道是否有人可以提供一些关于如何在woocommerce中隐藏类别的建议?

我在网上发现了一段代码添加到我的函数文件中,但遗憾的是它没有用,有语法错误。

基本上,如果您访问我的主页,您可以看到我们有一个圣诞类别(这显示在顶级类别轮播中)。 http://mrsbest.co.uk/

轮播动态显示所有类别,遗憾的是,这并不是指定各个类别的方法。

我不想删除或取消选中我的圣诞产品,所以只是想知道是否有隐藏特定类别的方法,当然我可以在下一个圣诞节重新介绍该类别!

这是我找到的代码不起作用:

/*--------------------------------------------------------------------------------------------------
 Don't show Categories -
--------------------------------------------------------------------------------------------------*/
add_filter( 'get_terms', 'get_subcategory_terms', 10, 3 );
function get_subcategory_terms( $terms, $taxonomies, $args ) {
 $new_terms = array();
 // if a product category and on the shop page
 if ( in_array( 'product_cat', $taxonomies ) && ! is_admin() ) {
 foreach ( $terms as $key => $term ) {
 if ( ! in_array( $term->slug, array( ‘christmas’ ) ) ) {
 $new_terms[] = $term;
 }
 }
 $terms = $new_terms;
 }
 return $terms;
}

希望你能帮忙!

非常感谢,

萨拉

0 个答案:

没有答案