我的自定义WP安装有一个单独的主题,将用于移动用户,在我的情况下,我需要在所有摘录实例中更改html标记,但在不更改DB的情况下,我发现这个简单的功能非常完美,但我无法使其工作,什么都没有发生。
function replace_content_on_the_fly($text){
$replace = array(
// \'words to find\' => \'replace with this\'
\'<p>\' => \'<div>\',
\'</p>\' => \'</div>\'
);
$text = str_replace(array_keys($replace), $replace, $text);
return $text;
}
add_filter(\'the_excerpt\', \'replace_content_on_the_fly\');
我在我的主题中添加了上述代码
function.php
. 为什么不起作用?