【发布时间】:2019-08-11 22:23:10
【问题描述】:
在 WooCommerce 档案页面上,我想在每个产品的标题下方添加一个副标题。
See this image for reference. 红色框表示子标题位置。
我尝试关注这个人 Add a custom field value below product title in WooCommerce archives pages ,但我无法使用自定义产品文本字段。
我的 Wordpress 主题 OceanWP 有一个 subheading field.
我试图从上面链接的帖子中更改代码,并想出了这个,但它不起作用:
add_action( 'woocommerce_after_shop_loop_item_title', 'subheading_display_below_title', 2 );
function subheading_display_below_title(){
global $product;
// Get the custom field value
$subheading = get_post_meta( $product->get_id(), '_subheading', true );
// Display
if( ! empty($subheading) ){
echo '<p class="subheading">'.$subheading.'</p>';
}
}
如何在产品存档页面的产品标题下方添加我的 OceanWP 产品副标题?
谢谢。
【问题讨论】:
标签: php wordpress woocommerce