几天前有个小伙伴曾问我

有没有自动将文章中出现的标签放上链接?

然后多次探索探究找到了自动将文章中出现的标签加链接的方法
教程开始

将下面的代码添加到主题的 functions.php 即可:
[hide]

/**
 * WordPress自动为文章标签添加该标签的链接
 * www.chichisvip.com
 */
function wpkj_auto_add_tag_link($content){
    $limit = 5; // 设置同一个标签添加几次链接
    $posttags = get_the_tags();
    if ($posttags) {
        foreach($posttags as $tag) {
            $link = get_tag_link($tag->term_id);
            $keyword = $tag->name;
            $cleankeyword = stripslashes($keyword);
            $url = '<a target="_blank" href="'.$link.'" title="'.str_replace('%s', addcslashes($cleankeyword, '$'), __('View all posts in %s')).'">'.addcslashes($cleankeyword, '$').'</a>';
            $regEx = '\'(?!((<.*?)|(<a.*?)))('. $cleankeyword . ')(?!(([^<>]*?)>)|([^>]*?</a>))\'s';
            $content = preg_replace($regEx,$url,$content,$limit);
        }
    }
    return $content;
}
add_filter( 'the_content', 'wpkj_auto_add_tag_link', 1 );

[/hide]
注意:根据自己的需要修改第7行的数字值。