批量替换WordPress文章中的文字的方法
1、首先登录wordpress后台。

2、其次,打开模板编辑。

3、打开主题的functions.php文件。

4、将下面代码加到主题的functions.php文件中:
function replace_text_wps($text){
$replace = array(
// '关键词' => '替换的关键词' 例如:
'wordpress' => '<a href="#">wordpress</a>',
'excerpt' => '<a href="#">excerpt</a>',
'function' => '<a href="#">function</a>'
);
$text = str_replace(array_keys($replace), $replace, $text);
return $text;
}
add_filter('the_content', 'replace_text_wps');
add_filter('the_excerpt', 'replace_text_wps');
声明:本网站引用、摘录或转载内容仅供网站访问者交流或参考,不代表本站立场,如存在版权或非法内容,请联系站长删除,联系邮箱:site.kefu@qq.com。
阅读量:57
阅读量:154
阅读量:165
阅读量:86
阅读量:158