手抄报 安全手抄报 手抄报内容 手抄报图片 英语手抄报 清明节手抄报 节约用水手抄报

批量替换WordPress文章中的文字的方法

时间:2024-10-30 12:00:21

1、首先登录wordpress后台。

批量替换WordPress文章中的文字的方法

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

批量替换WordPress文章中的文字的方法

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

批量替换WordPress文章中的文字的方法

4、将下面代码加到主题的functions.php文件中:functionreplace_text_wps($text){$replace=array(//'关键词'=>'替换的关键词' 例如:'wordpress'=>'<ahref="#">wordpress</a>','excerpt'=>'<ahref="#">excerpt</a>','function'=>'<ahref="#">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');

© 手抄报圈