I creating category page in my Woocommerce store. I want to display filters on the top. So I registered a new sidebar in my functions.php file, and put the code
<?php dynamic_sidebar( 'filters-1' ); ?>
in breadcrumb.php template file. So far, so good.
Now the idea is to convert filter attributes like: BLACK, WHITE, RED to color circles. So I think the best way to do this will be to add color attribute taxanomy as <li>
class, and then do some magic in CSS.
But the question is how co add a variable with attribute name/taxanomy into <li>
class of the attribute. Here is HTML output:
<ul class="woocommerce-widget-layered-nav-list">
<li class="woocommerce-widget-layered-nav-list__item wc-layered-nav-term ">
<a rel="nofollow" href="/?filter_color=black">Black</a> <span class="count">(2)</span>
</li>
<li class="woocommerce-widget-layered-nav-list__item wc-layered-nav-term ">
<a rel="nofollow" href="/?filter_color=white">White</a> <span class="count">(1)</span>
</li>
</ul>
I know there is a plugin to do this but I don't like plugins. :) I prefer to write some. I don't think extra plugin is necessary here.