I want to display the categories on my woocommerce page – all product loops.
I found a code to do this:
<code>add_action( 'woocommerce_shop_loop_item_title', function ( ){
global $product;
echo wc_get_product_category_list($product->get_id());
}, 1 );
</code>
<code>add_action( 'woocommerce_shop_loop_item_title', function ( ){
global $product;
echo wc_get_product_category_list($product->get_id());
}, 1 );
</code>
add_action( 'woocommerce_shop_loop_item_title', function ( ){
global $product;
echo wc_get_product_category_list($product->get_id());
}, 1 );
However the text does not look to good when more than one category (see image). So I wonder how I can add style to this? Maybe change the size of the font to 13px would make them fit one row. And also a bit of space between the category name and the product name would be nice.
How it looks now
Thank you!
I have added this code:
<code>add_action( 'woocommerce_shop_loop_item_title', function ( ){
global $product;
echo wc_get_product_category_list($product->get_id());
}, 1 );
</code>
<code>add_action( 'woocommerce_shop_loop_item_title', function ( ){
global $product;
echo wc_get_product_category_list($product->get_id());
}, 1 );
</code>
add_action( 'woocommerce_shop_loop_item_title', function ( ){
global $product;
echo wc_get_product_category_list($product->get_id());
}, 1 );
I tried some codes for font etc in the code but did not work.