Last active
December 12, 2015 01:58
-
-
Save eliorivero/4694709 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Show Woocommerce custom attributes | |
*/ | |
global $product; | |
$custom_attributes = array(); | |
foreach ( $product->get_attributes() as $slug => $attr ) { | |
$custom_attributes[] = $slug; | |
} | |
// This is fine for attributes set in Woocommerce > Attributes | |
// but not for attributes set in product editing screen | |
foreach ($custom_attributes as $custom_attribute) { | |
$many_values = array(); | |
foreach ( get_the_terms( $product->id, $custom_attribute) as $attr ) { | |
$many_values[] = $attr->name; | |
} | |
printf( | |
'<p>%s: %s</p>', | |
get_taxonomy($custom_attribute)->labels->name, | |
implode(', ', $many_values) | |
); | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment