Update 3 ( Automation for simple products, WC compatibility )
// Compatibility for WC 3+ and automation enhancements
add_action( 'woocommerce_shop_loop_item_title', 'custom_attributes_display', 20 );
function custom_attributes_display(){
global $product;
// Just for simple products
if( ! $product->is_type( 'simple' ) ) return;
$loop_count = 0;
echo '<div>';
// Get the attributes taxonomy slugs (Updated and dynamic now)
$attributes_taxonomy = $product->get_attributes();
// OR set an indexed array of taxonomy slug (key) and name (value) to chose which ones, like:
// $attributes_taxonomy = array('pa_nopeus' => 'Nopeus', 'pa_liito' => 'Liito, 'pa_vakaus' => 'Vaukaus' );
foreach( $attributes_taxonomy as $taxonomy => $attribute ) {
// Getting the term names of an attribute (set in a coma separated string if many values)
$attribute_terms = wp_get_post_terms( get_the_id(), $taxonomy, array( 'fields' => 'names' ) );
$terms_string = implode( ',', $attribute_terms );
// Displays only if attribute exist for the product
if( count( $attribute_terms ) > 0 ){ // Updated
echo $terms_string;
// Separating each number by a " | " (Updated and dynamic now)
$attr_count = count( $attributes_taxonomy );
$loop_count++;
if( $loop_count < $attr_count && $attr_count > 1 ) echo ' | ';
}
}
echo '</div>';
}
Update For WooCommerce version 3.0+ only.
// For WooCommerce Version 3.0+ (only)
add_action( 'woocommerce_shop_loop_item_title', 'custom_attributes_display', 20 );
function custom_attributes_display(){
// Just for product category archives pages
if(is_product_category()){
global $product;
// the array of attributes names
$attribute_names = array('pa_nopeus', 'pa_liito', 'pa_vakaus', 'pa_feidi');
foreach( $attribute_names as $key => $attribute_name ) {
// For WooCommerce version 3.0+
$product_id = $product->get_id(); // WC 3.0+
// Getting the value of an attribute (OK for WC 3.0+)
$wc_term = wc_get_product_terms( $product_id, $attribute_name);
$attribute_value = array_shift($wc_term);
// Displays only if attribute exist for the product
if(!empty($attribute_value) || '0' == $attribute_value ){ // Updated
echo $attribute_value;
// Separating each number by a " / "
if($key < 3) echo ' / ';
}
}
}
}
Code goes in function.php file of your active child theme (or theme) or also in any plugin file.
It should work now in WC 3.0+
Related to this Answer code: Display specific product attribute values on archives category pages