要做好wordpress网站的seo,在文章中添加关键词是非常有必要的,如果每次都手动添加,会比较麻烦。
下面给大家介绍一种非插件实现自动添加关键词的方法:
在主题函数functions.php中加入下面代码:
functionreplace_text_wps($text){ $replace=array( '518主题巴士'=>'<arel="externalnofollow"target="_blank"href="https://www.518theme.com"rel="bookmark"title="518主题巴士">518主题巴士</a>', '踏云网络'=>'<arel="externalnofollow"target="_blank"href="https://www.tayun123.com"rel="bookmark"title="踏云网络">踏云网络</a>' ); $text=str_replace(array_keys($replace),$replace,$text); return$text; }add_filter('the_content','replace_text_wps')
根据自己网站的需要,把关键词和链接添加进去即可,非常的方便。