自动为WordPress关键词添加链接(非插件)

为wordpress日志关键词添加链接,增加内链和外链,有利于SEO,实现上述功能一般我们会通过安装插件来实现,比如:WP Keyword Link和SEO Smart Link等。

利用《批量替换WordPress文章中的文字》一文的方法,不用插件也可以实现自动为关键词添加内链和外链。

将下面代码粘贴到主题functions.php文件中:

function replace_text_wps($text){
	$replace = array(  
		\'HotNews\' => \'<a href=\"https://zmingcx.com/\" rel=\"bookmark\" title=\"HotNews Pro主题\">HotNews</a>\',
		\'知更鸟\' => \'<a href=\"https://zmingcx.com/\" rel=\"bookmark\" title=\"知更鸟博客\">知更鸟</a>\',
		\'关键词\' => \'<a href=\"https://zmingcx.com/\" rel=\"bookmark\" title=\"说明\">关键词</a>\'
	);  
	$text = str_replace(array_keys($replace), $replace, $text);
	return $text;
}

add_filter(\'the_content\', \'replace_text_wps\');
    © 版权声明
    THE END
    喜欢就支持一下吧
    点赞0分享
    评论 抢沙发

    请登录后发表评论

      暂无评论内容