问题
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