'Wordpress | echo attribute_name and _value
I am using flatsome theme and i have a theme action hook called flatsome_product_box_after.
Basically he is located after the product picture on my Shop Catalogue.
Anyway: I managed to target the hook and if my products have the attribute pa_hersteller i want to echo the attribute_name and attribute_value of each product.
Right now i only have managed to echo "test". Any help to echo the attribute name and value is very appreciated. My Code so far:
function display_text_product_box_after() {
global $product;
$hersteller = $product->get_attribute('pa_hersteller');
if( ! empty($hersteller))
{
echo '<b style="color:black">test</b>';
}
}
add_action('flatsome_product_box_after', 'display_text_product_box_after');
Solution 1:[1]
I think this thread may help you.
Basically, the get_attribute() may not be available for your $product variable because $product is not of WC_Product instance.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Martin Lévai |
