Hello,
I have design issue with displaying related products on single product page for one category, where is just 2 products.
For other categories Related products are displayed properly below the short description of the product. I have tried to hide related products for that category (or tags) but none of this is working and i wonder if that theme related issue.
Could you advice how to hide related products for specific category or for specific tags or how to get in case of 2 products to show them also in bottom of the page?
I added to my childthemes functions file following:
function exclude_tags_from_related( $tags ){
// array of tags that should be excluded
$exclude_tags = array( ‘lisa’, ‘accessories’);
foreach( $tags as $index => $tag ){
if( in_array( $tag->slug, $exclude_tags ) ){
unset($tags[$index]);
}
}
return $tags;
}
add_filter( ‘woocommerce_get_related_product_tag_terms’, ‘exclude_tags_from_related’ );
In css related products are set clear: both
I have modified product page also as following:
/**
- Remove existing tabs from single product pages.
*/
remove_action( ‘woocommerce_after_single_product_summary’, ‘woocommerce_output_product_data_tabs’, 10 );
// remove default sorting dropdown
remove_action( ‘woocommerce_before_shop_loop’, ‘woocommerce_catalog_ordering’, 30 );
add_action( ‘woocommerce_after_single_product’, ‘woocommerce_upsell_display’, 15 );
/** woocommerce: change position of add-to-cart on single product **/
remove_action( ‘woocommerce_single_product_summary’,
‘woocommerce_template_single_add_to_cart’, 30 );
add_action( ‘woocommerce_single_product_summary’,
‘woocommerce_template_single_add_to_cart’, 9 );