WordPress无免费单机炸金花插件外部链接自动添加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主题设置有这个nofollow标签功能。
-
上一篇
-
下一篇
- 最近发表
- 随机阅读
-
- wordpress网站隐藏内容付费阅读/下载插件foxpay
- dedecms织梦5.7仿站视频教程(初级上部)
- dedecms织梦5.7仿站视频教程(初级下部)
- wordpress/帝国cms配置https(SSL)无法登录后台
- wppay免登录付费查看隐藏内容/付费资源下载
- 站长工具SEO综合查询那点事
- WordPress无插件外部链接自动添加nofollow标签
- 个人网站/公司logo标志免费在线制作
- 爱奇艺qsv/腾讯视频qlv/优酷视频kux格式转换MP4
- 仿新浪微博个人主页html网站模板
- CSS盒模型内边距padding外边距margin
- 站长工具SEO综合查询那点事
- 通过PhpMyAdmin找回wordpress登录密码
- wordpress博客新闻杂志主题SimultLite
- wordpress博客头部wp
- 通过PhpMyAdmin找回wordpress登录密码
- wordpress网站换域名搬家后打不开解决方法
- wordpress时光轴博客主题webnus下载
- 搜索引擎的工作原理(一)
- CSS表格table与列表list
- 搜索
-
- 友情链接
-