wordpress插件/WordPress SEO插件推荐:Nofollow for external link开心无限制

[wordpress插件] WordPress SEO插件推荐:Nofollow for external link开心无限制版

给WordPress文章或评论内容的站外链接添加Nofollow属性,在博客里编写文章的时候都会用到一些外链,外链这个东西根据每个人对SEO的理解层面不同所以运用上也都有不同的手法,非常多的站长在使用wordpress发表文章带外链的文章时都会给外链添加nofollow属性。

方法1:直接安装插件即可,不想用插件的可以参考方法2
方法2:打开我们所用的主题的模板函数文件,也就是functions.php 文件,将下面的代码加到模板函数里面,它会给外部链接自动添加

代码如下:

// 在主题模板functions.php文件中添加
add_filter('the_content', 'auto_nofollow'); //nofollow文章内容的站外链接
add_filter('comment_text', 'auto_nofollow'); //nofollow评论内容的站外链接
function auto_nofollow($content) {
//return stripslashes(wp_rel_nofollow($content));
return preg_replace_callback('/a]+/', 'auto_nofollow_callback', $content);
}
function auto_nofollow_callback($matches) {
$link = $matches[0];
$site_link = get_bloginfo('url');
if (strpos($link, 'rel') === false) {
$link = preg_replace(%(href=S(?!$site_link))%i, 'rel=nofollow $1', $link);
} elseif (preg_match(%href=S(?!$site_link)%i, $link)) {
$link = preg_replace('/rel=S(?!nofollow)S*/i', 'rel=nofollow', $link);
}
return $link;
}
// 在主题模板functions.php文件中添加
add_filter('the_content', 'auto_nofollow'); //nofollow文章内容的站外链接
add_filter('comment_text', 'auto_nofollow'); //nofollow评论内容的站外链接
function auto_nofollow($content) {
//return stripslashes(wp_rel_nofollow($content));
return preg_replace_callback('/a]+/', 'auto_nofollow_callback', $content);
}
function auto_nofollow_callback($matches) {
$link = $matches[0];
$site_link = get_bloginfo('url');
if (strpos($link, 'rel') === false) {
$link = preg_replace(%(href=S(?!$site_link))%i, 'rel=nofollow $1', $link);
} elseif (preg_match(%href=S(?!$site_link)%i, $link)) {
$link = preg_replace('/rel=S(?!nofollow)S*/i', 'rel=nofollow', $link);
}
return $link;
}
// 在主题模板functions.php文件中添加
add_filter('the_content', 'auto_nofollow'); //nofollow文章内容的站外链接
add_filter('comment_text', 'auto_nofollow'); //nofollow评论内容的站外链接
function auto_nofollow($content) {
//return stripslashes(wp_rel_nofollow($content));
return preg_replace_callback('/a]+/', 'auto_nofollow_callback', $content);
}
function auto_nofollow_callback($matches) {
$link = $matches[0];
$site_link = get_bloginfo('url');
if (strpos($link, 'rel') === false) {
$link = preg_replace(%(href=S(?!$site_link))%i, 'rel=nofollow $1', $link);
} elseif (preg_match(%href=S(?!$site_link)%i, $link)) {
$link = preg_replace('/rel=S(?!nofollow)S*/i', 'rel=nofollow', $link);
}
return $link;
}
// 在主题模板functions.php文件中添加
add_filter('the_content', 'auto_nofollow'); //nofollow文章内容的站外链接
add_filter('comment_text', 'auto_nofollow'); //nofollow评论内容的站外链接
function auto_nofollow($content) {
//return stripslashes(wp_rel_nofollow($content));
return preg_replace_callback('/a]+/', 'auto_nofollow_callback', $content);
}
function auto_nofollow_callback($matches) {
$link = $matches[0];
$site_link = get_bloginfo('url');
if (strpos($link, 'rel') === false) {
$link = preg_replace(%(href=S(?!$site_link))%i, 'rel=nofollow $1', $link);
} elseif (preg_match(%href=S(?!$site_link)%i, $link)) {
$link = preg_replace('/rel=S(?!nofollow)S*/i', 'rel=nofollow', $link);
}
return $link;
}

// 在主题模板functions.php文件中添加

add_filter(‘the_content’‘auto_nofollow’); //nofollow文章内容的站外链接

add_filter(‘comment_text’‘auto_nofollow’); //nofollow评论内容的站外链接

function auto_nofollow($content) {

//return stripslashes(wp_rel_nofollow($content));

return preg_replace_callback(‘/a]+/’‘auto_nofollow_callback’$content);

}

function auto_nofollow_callback($matches) {

$link = $matches[0];

$site_link = get_bloginfo(‘url’);

if (strpos($link‘rel’) === false) {

$link = preg_replace(%(href=S(?!$site_link))%i, ‘rel=nofollow $1’$link);

} elseif (preg_match(%href=S(?!$site_link)%i, $link)) {

$link = preg_replace(‘/rel=S(?!nofollow)S*/i’,

wordpress插件/WordPress SEO插件推荐:Nofollow for external link开心无限制

购买须知:
1. 因源代码属于知识性付费产品且具复制性,买家付款后将不支持以其他任何理由要求退款(为此请确保在演示站测试无误后再下单);
2. vip免费下载的源码均为未测试源码,不能保证源码完整均为框架,本站只收集搬运资源、我们不验证资源是否完整与可用,需要会员自行研究搭建测试 。
3. 该程序源码应在符合法律法规的条件下仅用于相关正规场景的测试、娱乐以及学习交流,不得用于商业活动及非法途径,如若违反国内外现行法律法规及其所产生的一切不良后果与本店无关,且本店有权单方暂停或终止服务,并享有持续追究其法律责任的权利;
4. 若您最终确认购买,则视为您认同并接受以上所述全部内容。
免责声明:
1.本文部分内容转载自其它媒体,但并不代表本站赞同其观点和对其真实性负责。
2.若您需要商业运营或用于其他商业活动,请您购买正版授权并合法使用。
3.如果本站有侵犯、不妥之处的资源,请在网站右边客服联系我们。将会第一时间解决!
4.本站所有内容均由互联网收集整理、网友上传,仅供大家参考、学习,不存在任何商业目的与商业用途。
5.本站提供的所有资源仅供参考学习使用,版权归原著所有,禁止下载本站资源参与商业和非法行为,请在24小时之内自行删除!
6.侵权联系邮箱:188773464@qq.com

moyy免费源码分享 建站模版类 wordpress插件/WordPress SEO插件推荐:Nofollow for external link开心无限制 https://moyy.us/9758.html

相关文章