首页 > CMS建站 > Wordpress > 正文

WordPress中批量替换正文程序代码

2020-06-10 12:58:09
字体:
来源:转载
供稿:网友

下面总结了两种关于WordPress中批量替换正文程序代码,一种是在mysql数据库中直接使用replace替换,另一种是修改functions函数来进行操作.

在 WordPress 主题的 functions.php 中插入以下代码:

  1. function content_str_replace($content = ''){ 
  2. $content = str_replace('old''new'$content); 
  3. return $content
  4. }//开源软件:Cuoxin.com 
  5. add_filter('the_content''content_str_replace', 10); 

和之前一样,其中 old 是旧的字符串,new 是你要替换的文字.

运行 SQL,输入以下语句即可:

UPDATE wp_posts SET post_content = replace(post_content, 'old', 'new');

其中 old 是旧的字符串,new 是你要替换的文字.

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表

图片精选