I’m using woocommerce as a catalog. I want to give css id each product category from category id. Because i want to make “display:none” in some where.
My codes looking in Chrome console like this:
<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>
My PHP codes:
<div class="woo-category">
<?php
$postid = get_the_ID();
$categories = get_the_term_list($postid, 'product_cat', '', ', ', '');
?>
<span><?php print_r($categories); ?></span>
</div>
I want to:
<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>
I think way is: print to category id as a css id but I don’t know how can i do that in PHP.
Best practice here is a custom loop. Try the following