WordPress给文章内容中指定关键词添加链接

作者: 站长 上传时间: 浏览: N/A 下载: N/A 格式: N/A 评分: N/A

function replace_text_wps($text){
$replace = array(
'悟空搜' => '<a href="https://yijile.com/tag/wordpress/" rel="tag" >悟空搜</a>',
'WordPress主题' => '<a href="https://xiaohost.com/theme" rel="category tag" >WordPress主题</a>',
'WrodPress教程' => '<a href="https://xiaohost.com/wplearn" rel="nofollow" target="_blank" >WrodPress教程</a>'
);
$text = str_replace(array_keys($replace), $replace, $text);
return $text;
}

add_filter('the_content', 'replace_text_wps');

使用方法

将下面代码粘贴到自己使用的Wordpress主题的functions.php文件中。

One thought on “WordPress给文章内容中指定关键词添加链接

Leave a Comment