Reputation: 123
I have a WordPress, WooCommerce based shop and I was wondering how can I display product attributes under product title on catalog page?
I guess it's just a filter needed to add, but how can I grab the values of the attributes of each product?
Upvotes: 1
Views: 2513
Reputation: 472
According to your query i can to use on wc_get_product_terms() method for this case as
in the products loop use
global $product;
$colors = array_shift( wc_get_product_terms( $product->id, 'pa_color', array( 'fields' => 'names' ) ) );
Otherwise
global $product;
$colors = $product->get_attribute( 'pa_color' );
OR using get_post_meta wp machanism as
$pa_color = get_post_meta($product->id, 'pa_color', true);
So use ,what are you want from above.
Thank you
Upvotes: 2