全网精品资源一站下载!

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

2023-02-14 来源:一曲源码   浏览 (1489)    权限组 : VIP免费下载   

  • 阿里云服务器一曲源码网
  • 广告位招租
  • [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', <span class="enlighter-s0" style="margin: 0px; padding: 0px; border: 0px; background-image: initial; background-position: initial; background-size: initial; background-repeat: initial; backgr

    注:本站所有源码支持免费互换,所有资源来源于网络,分享目的仅供大家学习和交流!不得使用于非法商业用途,不得违反国家法律。否则后果自负! 所有资源,不能保证完全去除后门!(建议先用D盾 等查杀软件先扫描一遍!)且都不包含技术服务请大家谅解!
    下载地址: 点击下载
    声明: 转载请注明来源(一曲源码)并保留原文链接:https://www.yiqucode.com/qitayuanma-4379.html
    根据二○○二年一月一日《计算机软件保护条例》规定:为了学习和研究软件内含的设计思想和原理, 通过安装、显示、传输或者存储软件等方式使用软件的,可以不经软件著作权人许可, 不向其支付报酬!鉴于此,也希望大家按此说明研究!
    本站所有源码均收集来源于网络,若此源码资源等文章侵犯您的合法权益,请私信联系站长,并于24小时内删除下架。
    本站所有源码仅限学习,交流使用,请勿上线或非法使用,一切法律责任均于此站无关。