您可以在函数中添加以下代码。php文件
function content_formatter($content){
$new_content = \'\';
$pattern_full = \'{(\\[raw\\].*?\\[/raw\\])}is\';
$pattern_contents = \'{\\[raw\\](.*?)\\[/raw\\]}is\';
$pieces = preg_split($pattern_full, $content, -1, PREG_SPLIT_DELIM_CAPTURE);
foreach ($pieces as $piece) {
if (preg_match($pattern_contents, $piece, $matches)) {
$new_content .= $matches[1];
} else {
$new_content .= wptexturize(wpautop($piece));
}
}
$array = array(
\'<p>[\' => \'[\',
\']</p>\' => \']\',
\']<br />\' => \']\'
);
$new_content = strtr($new_content, $array);
return $new_content;
}
现在在需要的地方调用此函数,如下所示;
<?php echo content_formatter( get_field(\'field_name\') ); ?>