Skip to content

Instantly share code, notes, and snippets.

@Veesibility
Last active August 29, 2015 14:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Veesibility/cefbb29f46bc29586e7c to your computer and use it in GitHub Desktop.
Save Veesibility/cefbb29f46bc29586e7c to your computer and use it in GitHub Desktop.
Woocommerce - Display Attributes Terms on Shop Page
/** 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