【发布时间】:2017-05-01 01:57:02
【问题描述】:
我有一个函数可以自动在我的标题周围添加一个跨度,以便我可以设置跨度的样式,例如:
<h2><span>my heading</span></h2>
这在我的正常 Wordpress 内容中运行良好,但高级自定义字段中的内容将其删除。有没有人有任何想法 - 花了几个小时在谷歌上搜索。
//add span into each title so can add flourish under span
add_filter('the_content', 'replace_content',1);
function replace_content($content) {
$content = preg_replace( '/<h(\d{1,6})(.*?)>(.*?)<\/h(\d{1,6}).*?>/', '<h$1><span>$3</span></h$4>', $content );
return $content;
}
非常感谢任何可以提供帮助的人!
【问题讨论】:
标签: php wordpress advanced-custom-fields