如何回应产品循环的某些woocommerce产品类别 [英] How do I echo certain woocommerce product category for product loop

查看:108
本文介绍了如何回应产品循环的某些woocommerce产品类别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,需要一些wordpress& woocommerce帮助到这里。



在content-product.php中,我看到这个代码回显了每个循环产品的所有产品类别。



Hello, needing some wordpress & woocommerce help here.

In content-product.php , I’ve seen this code echo all product categories for each loop product.

<?php if (etheme_get_option('product_page_cats')): ?>
            
                <div class="products-page-cats">
                    <?php 
                        $size = sizeof( get_the_terms( $post->ID, 'product_cat' ) );
                        echo $product->get_categories( ', ' ); 
						
                    ?>
                    
                </div>
	        <?php endif ?>







The line

echo $product->get_categories( ', ' );

显示该产品下的所有类别。

如果我想隐藏某些产品类别名称,该怎么办?我应该添加什么代码?



我尝试过:



- 一些谷歌搜索显示某些woocommerce产品类别,但没有有用的结果。

display all categories under that product.
What if I want to hide certain product category name from displaying. What code should I add?

What I have tried:

- Some googling on display certain woocommerce product category, but no useful result.

推荐答案

size = sizeof(get_the_terms(
size = sizeof( get_the_terms(


post-> ID,' product_cat'));
echo
post->ID, 'product_cat' ) ); echo


product-> get_categories(' ,');

?>

< < span class =code-leadattribute> / div >
<? php endif ?>
product->get_categories( ', ' ); ?> </div> <?php endif ?>







The line

echo


这篇关于如何回应产品循环的某些woocommerce产品类别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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