How to change woocommerce product title on loop

时间:2017-12-18 05:26:26

标签: wordpress woocommerce hook-woocommerce woothemes

how to change woocommerce product title on loop , for example change product tile in shop , category page etc ?

I am looking for the hook that can help to solve this issue . When go to woocommerce/content-product.php it is showing

<?php
                do_action( 'woocommerce_before_shop_loop_item_title' );

                echo '<div class="title-wrapper">';
                do_action( 'woocommerce_shop_loop_item_title' );
                echo '</div>';

please help

I want to change product tile on shop page , category page etc . But in single product page, or cart, checkout page i don't want to change title .Also what about shotcodes [products ids="12,34,56,"]; ? How can i change title ?

1 个答案:

答案 0 :(得分:2)

remove_action('woocommerce_shop_loop_item_title','woocommerce_template_loop_product_title',10);
add_action('woocommerce_shop_loop_item_title','fun',10);
function fun()
{
   echo 'Your Title for the product';
}

The above code will remove the Default Title and call another function which will show your own title in place. Now you have write your own logic for each product title. I tested with it, and it works for me.

Hope it works for you too.