在woocommerce商店的产品中隐藏一些类别名称 [英] hide some category names from products in woocommerce shop

查看:285
本文介绍了在woocommerce商店的产品中隐藏一些类别名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在woocommerce商店页面的产品说明中显示一些类别名称。通过下面的代码,我可以显示所有类别,但是我需要仅显示一些类别名称

I'd like to show some category names in the products description in my woocommerce shop page. With this code below, I'm able to show all the categories, but what I need is to show only some category names.

function wc_category_title_archive_products(){

$product_cats = wp_get_post_terms( get_the_ID(), 'product_cat' );

if ( $product_cats && ! is_wp_error ( $product_cats ) ){

    $single_cat = array_shift( $product_cats ); ?>

    <span class="categoria"><?php echo $single_cat->name; ?></span>



是否可以排除某些类别名称或显示只是我需要的?
谢谢

Is it possible to exclude some category names or show just the ones I need? thank you

推荐答案

WooCommerce 通过 WooCommerce>中的在类别页面上显示子类别和在商店页面上显示子类别选项在您的商店/类别页面中显示子类别。设置>目录>目录选项部分。

这些控件全有或全无:在类别页面上显示所有子类别,或在类别页面上显示所有子类别商店页面。如果要进行更细粒度的控制,例如仅在商店中显示某些子类别,或在给定类别目录页面上仅显示特定子类别,则需要编写一些自定义代码,并且可以采用两种方法。

These controls are all-or-nothing though: show all subcategories on the category pages, or show all subcategories on the shop page. If you want finer-grained control, for instance displaying only certain subcategories on the shop or particular subcategories on a given category catalog page, you’ll need to write a little custom code, and there are a couple of approaches you can take.

可在WooCommerce>设置>目录中找到的现有有限控件,可让您隐藏所有子类别或不隐藏任何子类别。

The existing limited controls, found in WooCommerce > Settings > Catalog, which allow you to hide all or none of the subcategories.

我建议在 https://wordpress.org/support/plugin/woocommerce#postform处提问,因此插件的开发人员和支持社区可以为此提供帮助。

I recommend asking at https://wordpress.org/support/plugin/woocommerce#postform so the plugin’s developers and support community can help you with this.

这篇关于在woocommerce商店的产品中隐藏一些类别名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆