Wordpress - Display single product attribute value on Shop page (Woocommerce)
Just use global $product
then use get_attribute()
method of that product object, like below-
$size = $product->get_attribute( 'pa_size' );
And you can also get that by below code-
global $product;
$size = array_shift( wc_get_product_terms( $product->id, 'pa_size', array( 'fields' => 'names' ) ) );
Rememeber you need to use must the global $product
.