I want to show specific product attributes on category page in WooCommerce. Attributes would be shown after the product title, before the short description.
The attributes are pa_nopeus
, pa_liito
, pa_vakaus
and pa_feidi
. They are only numerical values. I just want to show the values and not the names, pretty much like this:
Product Name
4 / 4 / 1 / 2
Short description
If these values do not exist in the product, line would not be shown at all.
I want to add this to the (template) code and not by using a plugin. I believe it will be added to content-product.php.
#content-product.php start....
do_action( 'woocommerce_shop_loop_item_title' );
VALUES HERE SOMEHOW?
/**
* woocommerce_after_shop_loop_item_title hook.
*
* @hooked woocommerce_template_loop_rating - 5
* @hooked woocommerce_template_loop_price - 10
*/
do_action( 'woocommerce_after_shop_loop_item_title' );
#rest of the content-product.php...
How can I achieve this?
Thanks
In this case the code below goes on function.php file of your active child theme (or theme).
Here is the code:
So you will get just after the title, on product category archives pages what you are expecting.
Or alternatively you can use the code above in the template
content-product.php
, this way:But the first solution is more recommended and elegant.
The code is tested and works