wp php get product attribute name without pa
- Access the product object:
$product = wc_get_product( $product_id );
- Get the product attributes:
$attributes = $product->get_attributes();
- Iterate through the attributes:
foreach ( $attributes as $attribute ) {
- Check if the attribute is not a variation attribute ('pa_' prefix):
if ( 0 !== strpos( $attribute['name'], 'pa_' ) ) {
- Get the attribute name:
$attribute_name = wc_attribute_label( $attribute['name'] );
- Output or use the attribute name as needed:
echo $attribute_name;
}
}