下面总结了两种关于WordPress中批量替换正文程序代码,一种是在mysql数据库中直接使用replace替换,另一种是修改functions函数来进行操作.
在 WordPress 主题的 functions.php 中插入以下代码:
function content_str_replace($content = ''){
$content = str_replace('old', 'new', $content);
return $content;
}//开源软件:phpfensi.com
add_filter('the_content', 'content_str_replace', 10);
和之前一样,其中 old 是旧的字符串,new 是你要替换的文字.
运行 SQL,输入以下语句即可:
UPDATE wp_posts SET post_content = replace(post_content, 'old', 'new');
其中 old 是旧的字符串,new 是你要替换的文字.