WordPress评论者主页链接新窗口打开
作者:dianso 发布时间:April 7, 2010 分类:存檔備份,談博說博
在虎头鱼那看到了通过修改 wordpress 文件的方法做到评论者主页链接新窗口打开,我嫌麻烦,于是放狗搜索了下,找到了个方法。
只需要把的下面的代码复制到主题的 function.php 中就可以了。
// Make comment author link URL open in new window function comment_author_link_window() { global $comment; $url = get_comment_author_url(); $author = get_comment_author(); if ( empty( $url ) || 'http://' == $url ) $return = $author; else $return = "<a href='$url' rel='external nofollow' target='_blank'>$author</a>"; return $return; } add_filter('get_comment_author_link', 'comment_author_link_window');
如果非要用标准的 external,那么我推荐这种方法,在 header.php 加入:
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script> <script type="text/javascript"> $(document).ready(function(){$("a[rel='external'],a[rel='external nofollow']").click(function(){window.open(this.href);return false})}) </script>
然后 function.php 加入:
// Make comment author link URL open in new window function comment_author_link_window() { global $comment; $url = get_comment_author_url(); $author = get_comment_author(); if ( empty( $url ) || 'http://' == $url ) $return = $author; else $return = "<a href='$url' rel='external nofollow' rel='external'>$author</a>"; return $return; } add_filter('get_comment_author_link', 'comment_author_link_window');
Dianso‘s Blog
加了个target='_blank' 测试一下
:razz: 俺是菜鸟,学习中!
应该也是target='_blank'
怎么最经这个主题这么流行
我也设置全部链接都设置为默认新窗口打开
高亮代码的颜色样式不错。哈 :razz:
我一般都是右键新窗口打开
我去别人的站也是右键新窗口打开,现在又换回原来的主题了,默认新页面打开
第一种简单些,至于标准性的东西以后再说,方便为主 :grin:
:roll:
正在计划改成这样的呢。不知道有没有什么影响啊?
external需要JS的支持,比起target='_blank',更符合w3标准
[...] 9);以上代码修改来源:http://www.catswhocode.com/blog/10-useful-new-wordpress-hackshttp://014.cc/874让垃圾留言/评论制造者们全部傻眼去吧! [...]
copy走了。。
我的升级3.0.2后发现该源文件已经不行了,刚好找到你这个,呵呵,谢谢博主~
哈 主题很古典
侧边栏还有毛泽东语录 赞
不错正在找呢,感谢分享.
为什么我自己找不到 :sad:
@歪歪: 找不到什么呢?
gdsae坑的思考过后十多个开始的后果!