WordPress无线上网投赏金女王2块爆分13万在澳门的合法性插件外部链接自动添加nofollow标签
如果手动每个链接加入是很麻烦,可以直接找一些wordpress插件安装。当然我们也可以通过代码实现无插件添加方法。
//文章自动nofollowadd_filter( 'the_content', 'tin_seo_wl');function tin_seo_wl( $content ) { $regexp = "<a\s[^>]*href=(\"??)([^\" >]*?)\\1[^>]*>"; if(preg_match_all("/$regexp/siU", $content, $matches, PREG_SET_ORDER)) { if( !empty($matches) ) { $srcUrl = get_option('siteurl'); for ($i=0; $i < count($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写文章时,
- 最近发表
- 随机阅读
-
- wordpress用户头像无法(自定义)本地上传修改
- 利用excel分析IIS服务器日志
- 常用SEO命令/站长工具使用
- 个人网站阿里云IPC备案10天办理完成
- 百度搜索引擎搜索查询的表现形式
- wordpress未能与站点联系致命错误,PHP修改被回滚
- 宝塔Linux面板地址/用户名密码忘记找回方法
- CSS文本样式字体font
- css中position属性定位:absolute与relative
- 网站优化之百度快照更新分析
- 小米智能门锁2指静脉增强版震撼登场:AI猫眼+可视大屏,安全又便捷,仅售1699元!
- 个人网站香港主机野草云选购
- wordpress评论者链接在新窗口打开
- wordpress简约清新范博客主题Pinghsu
- web前端开发表单form/input标签
- SEO搜索引擎的起源/发展
- UNI Slumps 17% Following SEC Developments, BTC, ETH, DOGE, TON on the Rise (Market Watch)
- CSS背景background样式属性设置
- (扒站工具)如何下载网站fonts文件夹
- wordpress XIU主题(阿里百秀)小清新cms模板V5.6
- 搜索
-
- 友情链接
-