wordpress留言用户名称的设置comment_author_link

原文链接:http://www.maninmusic.com/3445.html

该标签显示带有链接的评论作者名,链接指向评论作者所提供的URL。该标签必须用在WordPress主循环(loop)或评论循环中。

如果用默认的

<?php comment_author_link(); ?>

显示出来的是

<a href="留言用户网址" rel="external nofollow" class="url">留言用户名称</a>

但是如果我们不想在本页打开,那就要添加target=”_blank”,我们可以用下面的改进代

comment_author()是获取用户名

comment_author_url()是获取用户的网址

<?php if(!get_comment_author_url()) : ?>
   <?php comment_author(); ?>
   <?php else : ?>
      <a href="<?php comment_author_url(); ?>" target="_blank" rel='nofollow'><?php comment_author(); ?></a>
<?php endif; ?>