Add a product subtitle in Woocommerce archives pages

冷暖自知 提交于 2021-02-05 09:23:31

问题


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:

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


回答1:


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>';
}

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



来源:https://stackoverflow.com/questions/52564569/add-a-product-subtitle-in-woocommerce-archives-pages

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!