Woocommerce, recognize the loop of related products
from https://businessbloomer.com/woocommerce-conditional-logic-ultimate-php-guide/ global $woocommerce_loop; if ( is_product() && $woocommerce_loop[‘name’] == ‘related’ ) { add_action(‘woocommerce_after_shop_loop_item_title’,’your_custom_function’,20); }