WordPress.org

Ready to get started?Download WordPress

Forums

How To Add Target="_bank" In Comments.php (3 posts)

  1. garryconn
    Member
    Posted 6 years ago #

    Hello!

    Comment.php has this line of code:

    <cite><?php comment_author_link() ?></cite> Says:

    How do I use Target="_blank" so that when people click on the names it opens the link in a new window?

  2. Kalon
    Member
    Posted 6 years ago #

    Try:

    <cite><a href="<?php comment_author_url(); ?>" target="_blank"><?php comment_author(); ?></a></cite>
  3. Zoinks! Graphics
    Member
    Posted 5 years ago #

    Sweet! Thank you, Kalon. Your code helped me with my blog!!

    I adjusted it to account for comment authors who don't have a site address...

    echo '<cite>';
    
    if(get_comment_author_url())
    	{
    	echo '<a href="' . get_comment_author_url() .
    	'" target="_blank" title="Website of ' .
    	get_comment_author() . '">' . get_comment_author() . '</a>';
    	}
    else	{ comment_author(); }
    
    echo '</cite>';

Topic Closed

This topic has been closed to new replies.

About this Topic