将以下代码添加到当前主题的functions.php文件中保存:
代码中注释的很清楚,可以自行改正。
二、指定关键词自动内链
将以下代码添加到当前主题的functions.php文件中保存:
/* 文章指定关键词添加内链开始 */ function replace_text_wps($text){ $replace = array( '云瓜网' => '<a href="https://www.cloudgua.com/" target="_blank" title="云瓜网">云瓜网</a>', '云瓜网' => '<a href="https://www.cloudgua.com/" target="_blank" title="云瓜网">云瓜网</a>', '教程' => '<a href="https://www.ztmbk.com/jiaocheng/" rel="external nofollow" target="_blank" title="教程">教程</a>' ); $text = str_replace(array_keys($replace), $replace, $text); return $text; } add_filter('the_content', 'replace_text_wps');
大家自行把代码中的关键词与链接换成自己的,需要其他关键词复制那一行代码即可,非常方便,这个方法有个缺陷就是不能控制关键词锚文本次数,只要在文章中出现的关键词不管几次都会加上链接