I'm building a shop in WP + WooCommerce. I have different types of product categories like discs and bags. For discs products I have some specific attributes like Speed, Glide, Turn and Fade that don't have any other product categories. I want to display these product attribute values only on shop pages under the product picture.
I have found one code for that and I added myself a separation symbol "|", but this separation symbol is now displayed under all the products that are variable.
Is it possible to change the code not to variables but only for specific product categories and sub-categories?
Code:
add_action( 'woocommerce_before_shop_loop_item_title', 'display_size_attribute', 5 );
function display_size_attribute() {
global $product;
if ( $product->is_type('variable') ) {
$taxonomy = 'pa_speed';
echo '<span class="attribute-speed">' . $product->get_attribute($taxonomy) . '</span>' ;
echo ' | ';
$taxonomy = 'pa_Glide';
echo '<span class="attribute-Glide">' . $product->get_attribute($taxonomy) . '</span>';
echo ' | ';
$taxonomy = 'pa_Turn';
echo '<span class="attribute-Turn">' . $product->get_attribute($taxonomy) . '</span>';
echo ' | ';
$taxonomy = 'pa_Fade';
echo '<span class="attribute-Fade">' . $product->get_attribute($taxonomy) . '</span>';
}
}