3

A question about WooCommerce/Wordpress

Is there a way to recognize which loop you are in?

If I wanted use the hook woocommerce_after_shop_loop_item_title only in the loop of related products, how can i do?

thanks

1 Answer 1

10

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);
}
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.