【发布时间】:2020-09-07 20:08:40
【问题描述】:
我希望能够在我的产品标题中添加一个“li”标签。为了以用户友好的方式实现这一点,我编写了一个将字符“-”更改为“li”标签的代码。 但目前 html 对“order-details-table”(例如,当您完成订购时出现)没有影响。是否有另一个过滤器可以全局添加 html,因此每次标题出现时它都会将“-”更改为“li”? --> 我更新了我的代码,现在 html 到处都出现了,只有以下问题剩余:
然而,在后端添加了 html,但显示为纯文本,因此它没有效果。这个问题也有解决办法吗?
What the product title looks like at the moment --> the html gets interpreted as normal text
add_filter( 'the_title', 'custom_the_title', 10, 2 );
add_filter( 'woocommerce_cart_item_name', 'custom_the_title', 20, 3);
add_filter( 'woocommerce_order_item_name', 'custom_the_title' );
function custom_the_title( $title){
$title = str_replace( '-', '<li>', $title );
$title = str_replace( '.', '</li>', $title );
return $title;
}
非常感谢您的帮助,以及来自奥地利的问候! 塞缪尔
【问题讨论】:
-
这可能与您的问题stackoverflow.com/questions/46412614/…有关
-
是的,这是我的一些代码行......但是使用这篇文章中提供的 sn-p,订单详细信息表和购物车中的标题没有改变。 ..
标签: wordpress woocommerce