我正在使用woocommerce作为目录。我想给类别ID的每个产品类别的CSS ID。因为我想在某些地方制作“display:none”。如何在Wordpress中从产品类别名称获取css ID
我看的代码在Chrome控制台像这样:
<div class="woo-category">
<span>
<a href="http://www.yazicimakina.com.tr/?product_cat=overlap" rel="tag">Overlap</a>
","
<a href="http://www.yazicimakina.com.tr/?product_cat=tam" rel="tag">TAM</a>
","
<a href="http://www.yazicimakina.com.tr/?product_cat=tumu" rel="tag">TÜMÜ</a>
</span>
</div>
我的PHP代码:
<div class="woo-category">
<?php
$postid = get_the_ID();
$categories = get_the_term_list($postid, 'product_cat', '', ', ', '');
?>
<span><?php print_r($categories); ?></span>
</div>
我想:
<div class="woo-category">
<span>
<a id="example1" href="http://www.yazicimakina.com.tr/?product_cat=overlap" rel="tag">Overlap</a>
","
<a id="example2" href="http://www.yazicimakina.com.tr/?product_cat=tam" rel="tag">TAM</a>
","
<a id="example3" href="http://www.yazicimakina.com.tr/?product_cat=tumu" rel="tag">TÜMÜ</a>
</span>
</div>
我想方式是:打印到类别ID作为一个CSS ID,但我不知道我怎么能在PHP中做到这一点。
答案是get_the_term_list某处()函数 – 2015-01-21 09:19:14