• 首页
  • WordPress下载
  • WordPress教程
  • 酱茄Free主题
  • WordPress小程序
    • 酱茄Pro小程序(社区+商城)
    • 酱茄Cms小程序(积分阅读)
    • 酱茄Free小程序(免费下载)
  • 首页
  • WordPress下载
  • WordPress教程
  • 酱茄Free主题
  • WordPress小程序
    • 酱茄Pro小程序(社区+商城)
    • 酱茄Cms小程序(积分阅读)
    • 酱茄Free小程序(免费下载)

怎么给WordPress文章外链地址添加nofollow

2020-10-04
in WordPress教程
0

在当前WordPress模板主题函数文件functions.php中添加以下代码,即可轻松给WordPress文章外链地址添加nofollow。

nofollow是什么

nofollow是HTML页面中a标签的属性值。它的出现为网站管理员提供了一种方式,即告诉搜索引擎"不要追踪此网页上的链接"或"不要追踪此特定链接"。这个标签的意义是告诉搜索引擎这个链接不是经过作者信任的,所以这个链接不是一个信任票。(本段来自百度百科)

//WordPress给文章外链添加nofollow
add_filter('the_content','web589_the_content_nofollow',999);
function web589_the_content_nofollow($content){
	preg_match_all('/href="(.*?)" rel="external nofollow" /',$content,$matches);
	if($matches){
		foreach($matches[1] as $val){
			if( strpos($val,home_url())===false ) $content=str_replace("href=\"$val\"", "href=\"$val\" rel=\"nofollow\" ",$content);
		}
	}
	return $content;
}

 

Tags: nofollow是什么WordPressWordPress主题WordPress模板
Previous Post

WordPress删除文章时怎么自动删除文章内的图片附件

Next Post

WordPress插件怎么安装(3种安装方式)

Please login to join discussion

酱茄Pro小程序

热门标签

Elementor Login Designer nofollow是什么 Pure-Highlightjs Safe SVG TinyPNG Twenty Twenty One woocommerce WooCommerce商城 WordPress WordPress 5.6 WordPress 5.6下载 WordPress下载 WordPress主题 WordPress仪表盘 WordPress函数 WordPress官网 WordPress小程序 WordPress建站 WordPress忘记密码 WordPress插件 WordPress教程 WordPress模板 WP Admin Cache WP Dark Mode WP Mail SMTP WP Term Order 什么是SVG 代码高亮 区块编辑器 古腾堡 小程序 小程序源码 标签 知识付费小程序 追格 酱茄 酱茄cms 酱茄Free 酱茄Free主题 酱茄Free小程序 酱茄Pro 酱茄主题 酱茄小程序 酱茄小程序开源版

广告推荐

酱茄Cms小程序

  • 关于/联系
  • 免责声明
  • 用户协议
  • 隐私政策
  • 网站地图
  • Feed

Copyright © 2021 追格 京ICP备16067668号 京公网安备 11010802022707号

No Result
View All Result
  • 首页
  • WordPress下载
  • WordPress教程
  • 酱茄Free主题
  • WordPress小程序
    • 酱茄Pro小程序(社区+商城)
    • 酱茄Cms小程序(积分阅读)
    • 酱茄Free小程序(免费下载)

Copyright © 2021 追格 京ICP备16067668号 京公网安备 11010802022707号

Welcome Back!

Login to your account below

Forgotten Password?

Create New Account!

Fill the forms below to register

All fields are required. Log In

Retrieve your password

Please enter your username or email address to reset your password.

Log In