在Woocommerce存档页面中添加产品字幕 [英] Add a product subtitle in Woocommerce archives pages

查看:54
本文介绍了在Woocommerce存档页面中添加产品字幕的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以通过将以下代码添加到single-product/title.php中来为产品标题添加字幕:

I can add a subtitle to my product title by adding the following code to single-product/title.php:

the_title( '<h1 class="product_title entry-title">', '</h1>' );
echo "<p>My subtile</p>";

问题在于,它仅出现在产品页面上.不在商店视图等其他视图上:

The problem is that this only appears on the product page. Not on other views such as the shop view:

我到处都看过,找不到WooCommerce商店其他视图的标题在哪里修改?

I have looked everywhere and cannot find out where to modify the title for other views of the WooCommerce store?

推荐答案

已更新-要在诸如shop之类的存档页面中添加产品字幕,请使用以下命令:

Updated - To add a product subtitle in archives pages like shop use the following:

add_action( 'woocommerce_shop_loop_item_title', 'woocommerce_shop_loop_item_subtitle', 20 );
function woocommerce_shop_loop_item_subtitle() {
    global $product;

    echo '<p>' . __("My subtile", "woocommerce") . '</p>';
}

代码进入您的活动子主题(或活动主题)的function.php文件中.经过测试,可以正常工作.

Code goes in function.php file of your active child theme (or active theme). Tested and works.

这篇关于在Woocommerce存档页面中添加产品字幕的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆