如何批量替换或者删除wordpress文章中的文字

时间:2026-02-12 09:14:13

1、在WordPress主题 的 functions.php 文件中添加如下代码:

2、function replace_text_xintheme($text){

    $replace = array(

        //'关键词' => '将要替换的关键词'

        '例子' => '案例',

'WordPress' => 'WordPress主题',

    );

    $text = str_replace(array_keys($replace), $replace, $text);

    return $text;

}

add_filter('the_content', 'replace_text_xintheme');

add_filter('the_excerpt', 'replace_text_xintheme');

3、按照上面的方法就可以了,是不是很简单快速呢?

© 2026 海能知识库
信息来自网络 所有数据仅供参考
有疑问请联系站长 site.kefu@gmail.com