如何循环更改woocommerce产品标题 [英] How to change woocommerce product title on loop
问题描述
如何在循环中更改woocommerce产品标题,例如在shop , category
页面中更改产品图块等?
how to change woocommerce product title on loop , for example change product tile in shop , category
page etc ?
我正在寻找有助于解决此问题的挂钩.转到woocommerce/content-product.php
时显示
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>';
请帮助
我想更改shop page , category page
等上的产品图块.但是在single product page, or cart, checkout
页面中,我不想更改标题.镜头代码[products ids="12,34,56,"];
又如何呢?如何更改标题?
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 ?
推荐答案
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.
希望它也对您有用.
这篇关于如何循环更改woocommerce产品标题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!