我们在优化WordPress网站的时候,经常会遇到替换或删除文章中的内容,内容多的时候手动删除修改太麻烦了。
今天追格小编就来给大家分享如何快速批量修改WordPress文章中的文字。
在当前使用的WordPress主题的函数文件functions.php中添加以下代码即可:
function replace_text_zhuige($text){
$replace = array(
//'新关键词' => '旧关键词'
'新关键词'=> '旧关键词',
);
$text = str_replace(array_keys($replace), $replace, $text);
return $text;
}
add_filter('the_content', 'replace_text_zhuige');
add_filter('the_excerpt', 'replace_text_zhuige');