Last active
August 29, 2015 14:23
-
-
Save Veesibility/cefbb29f46bc29586e7c to your computer and use it in GitHub Desktop.
Woocommerce - Display Attributes Terms on Shop Page
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
/** This code should be added to functions.php of your theme **/ | |
/* Display Attributes Terms on Shop Page */ | |
add_action( 'woocommerce_after_shop_loop_item_title', 'vee_add_attributes_terms', 1); | |
function vee_add_attributes_terms() { | |
$attributes_name = get_the_terms( $product->id, 'pa_attribute'); // Replace "pa_attribute" by your attribute | |
if ( $attributes_name && ! is_wp_error( $$attributes_name )): | |
foreach ( $attributes_name as $attributes_name ) | |
{ | |
echo '<span class="my_custom_class">'.' '.$attributes_name->name.' '.'</span>'; // Add custom class to style | |
} | |
endif; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment