WordPress评论者主页链接新窗口打开

虎头鱼那看到了通过修改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');

{ 发表评论? }

  1. 士大夫

    gdsae坑的思考过后十多个开始的后果!

发表评论

电子邮件地址不会被公开。

 smiles smiles smiles smiles smiles smiles smiles smiles smiles smiles smiles smiles smiles smiles smiles smiles smiles smiles smiles smiles smiles smiles

您可以使用这些 HTML 标签和属性: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Pingback & Trackback

  1. 移除 WordPress 评论者和评论内容链接 - 走点路博客 - Pingback on 2010/10/10/ 12:08

无觅相关文章插件,快速提升流量