您应该尝试以下操作:
function replace_tag($string){
$search = array(\'<p>\', \'</p>\');
$replace = array(\'<h2>\', \'</h2>\');
echo str_replace($search, $replace, $string);
return $string;
}
add_filter(\'the_excerpt\', \'replace_tag\');
或者这个:
function replace_tag($string){
$replace = array(
\'<p>\' => \'<h2>\',
\'</p>\' => \'</h2>\'
);
$string = str_replace(array_keys($replace), $replace, $string);
return $string;
}
add_filter(\'the_excerpt\', \'replace_tag\');