在wordpress写文章时,严格要求的话是需要在外部链接全部加上nofollow标签。在技术层面是有传递出去权重。当然我们也可以通过代码实现无插件添加方法。有些外部链接是没有加Nofollow标签,华体育会app官方下载官网问鼎下载何常在可以直接找一些wordpress插件安装。这样所有的外部链接就会自动加上nofollow标签。如果手动每个链接加入是很麻烦,
//文章自动nofollowadd_filter( 'the_content', 'tin_seo_wl');function tin_seo_wl( $content ) { $regexp = "<a\s[^>]*href=(\"??)([^\" >]*?)\\1[^>]*>"; if(preg华体育会app官方下载官网_match_all("/$regexp/siU", $content, $matches, PREG_SET_ORDER)) { if( !empty($matches) ) { $srcUrl = get_option('siteurl'); for ($i=0; $i < cou问鼎下载何常在nt($matches); $i++) { $tag = $matches[$i][0]; $tag2 = $matches[$i][0]; $url = $matches[$i][0]; $noFollow = ''; $pattern = '/target\s*=\s*"\s*_blank\s*"/'; preg_match($pattern, $tag2, $match, PREG_OFFSET_CAPTURE); if( count($match) < 1 ) $noFollow .= ' target="_blank" '; $pattern = '/rel\s*=\s*"\s*[n|d]ofollow\s*"/'; preg_match($pattern, $tag2, $match, PREG_OFFSET_CAPTURE); if( count($match) < 1 ) $noFollow .= ' rel="nofollow" '; $pos = strpos($url,$srcUrl); if ($pos === false) { $tag = rtrim ($tag,'>'); $tag .= $noFollow.'>'; $content = str_replace($tag2,$tag,$content); } } } } $content = str_replace(']]>', ']]>', $content); return $content;}
添加到当前主题Funcions.php 文件中,
当然目前一些wordpress主题设置有这个nofollow标签功能。有时内容会引用或分享一些外部链接地址, 顶: 8踩: 34537
WordPress无华体育会app官方下载官网插件外部链接自动添加nofollow标签问鼎下载何常在
人参与 | 时间:2025-06-23 01:24:50
相关文章
- boke字母拼音是什么意思?
- B站视频下载软件工具推荐
- WordPress网站外链添加GO跳转提示代码
- 织梦提示Fatal error: Call to undefined function make
- 谷歌Nest音箱升级“翻车”:部分用户更新后成砖,AI助手Gemini遭质疑
- Crypto Markets in Retreat: BTC Losses $70K, WIF Plummets 11% Daily (Market Watch)
- QQ空间心情说说日志类网站织梦模板(带手机端)
- HTML+JavaScript创建响应式404页面
- WordPress音乐主题Always1.8使用教程
- WordPress外链图片插件Featured Image from URL
评论专区