WordPress给文章内容中指定关键词添加链接
2022-07-29 10:13:20
104
{{single.collect_count}}

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

使用方法

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

function replace_text_wps($text){$replace = array('源日记' => '<a href="https://320w.com/tag/wordpress/" rel="tag" >源日记</a>','WordPress主题' => '<a href="https://www.320w.com/wordpress/wordpress-theme" rel="category tag" >WordPress主题</a>','WrodPress教程' => '<a href="https://www.320w.com/wordpress/wordpress-wplearn" rel="nofollow" target="_blank" >WrodPress教程</a>');$text = str_replace(array_keys($replace), $replace, $text);return $text;}add_filter('the_content', 'replace_text_wps');
回帖
全部回帖({{commentCount}})
{{item.user.nickname}} {{item.user.group_title}} {{item.friend_time}}
{{item.content}}
{{item.comment_content_show ? '取消' : '回复'}} 删除
回帖
{{reply.user.nickname}} {{reply.user.group_title}} {{reply.friend_time}}
{{reply.content}}
{{reply.comment_content_show ? '取消' : '回复'}} 删除
回帖
收起
没有更多啦~
{{commentLoading ? '加载中...' : '查看更多评论'}}