Comment Author link to Open in New Window

Comment Author link in WordPress, by default, opens up in the SAME WINDOW.  That is such a No-No!  Your visitors leave your site as soon as they click the Comment Author’s link!

comment author link on wordpress

Comment Author’s link – outgoing to his site

This was brought to my attention when I received my first (lovely) comment from Jupiter Jim on my 10-day old site, right here.  As soon as I approved it, and then went about clicking his name (which, because he left a web address, linked to his site), I noticed that it was trying to open that page right in “my” window.  No No No!

Personal Aside to Jupiter Jim: I hope you don’t mind me using your lovely photo & comment excerpt here for illustration!

 

What you really want is for that Comment Author link, when clicked, to open up in a NEW WINDOW.  That way, your visitors don’t just abandon your site.  You would like them to stay around and shoot the breeze with you for a while longer.

Sidenote: Comment Author link is the URL/web address that is (optionally) typed in by the person who leaves a comment on your post.  If it is not spam (to some useless, annoying, advertising site of zero value), then it normally links to the person’s own website.  In other words, this link (on your site) links back to the Comment Author’s site.  This is good for that site’s SEO because the more legitimate links going to a person’s site, the better.  So LEAVE A COMMENT BELOW!  (Hint Hint!)

 

How to Open Comment Author’s Link in a New Window

There seems to be no easy way in the WP (WordPress) Admin area to accomplish this.  So Googling I went.

I came across a number of potential solutions but they all involved coding and fiddling with your WordPress theme’s .php files.  Not my preferred choice if I can help it.  (The references at the bottom lead to some of those potential solutions I found.)

I found my (partial) solution from Studiograsshopper’s “Open comment author link in new window“.

Genesis Theme Framework for WordPress

Yes, happiness with Genesis Framework = aff link!

 

I say “partial” because my situation is that I am using Genesis framework with a child theme (of course):  Prose Theme (<= Yes Yes Yes! I am so happy with Genesis, I became an affiliate.)

 

I know with Genesis framework, you DO NOT want to go fiddling around with any of Genesis’s core files and functions.  You can modify its child theme’s files and functions. (That way, when Genesis provides automatic updates to better safeguard and optimize your Genesis driven WordPress site, all the customizations you have laboriously achieved with your child theme will remain intact; upgrade after upgrade.)

So keep in mind, what follows is the solution particular to MY situation.  That is not to say that it might not apply to you too and/or that you won’t find within it nuggets that will help you ensure that your comment author links also appropriately open in a new tab/window.

Remember: My Criteria for an ideal solution on how to make Comment Author links open in New Tab/Window are –

  • I am not going to touch Genesis Framework core files in anyway.
  • I prefer not to have to create/modify any .php files – especially via FTP

I have always said: Simple Simple Solutions for me please!

Step 1

I  copied the code needed for this custom function from Studiograsshopper’s “Open comment author link in new window” (reproduced below).


//* 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 = "$author";
	return $return;
}
add_filter('get_comment_author_link', 'comment_author_link_window');
genesis custom code area

Genesis Framework: Use Custom Code for you customised css and functions

 

Step 2

In Genesis, to prevent users accidentally mucking up the php code, css, and functions etc, they provide an easy section in the WP Admin area to modify/add/delete our own specific custom coding.

WP Admin >> Genesis >> Custom Code

Then in the “Custom Functions” area, I copied and pasted the needed code.

genesis custom functions

Add code in Custom Functions area

What can I say but “Yippee!”  Now all Comment Author links on this site will appropriately open up in a new window!

 


Note: Added 15 Aug 2013

re. Genesis Child Theme: Eleven40 Pro
The php code given on this page does NOT work with child theme Eleven40 Pro.


 

Reference for those who need more:

 

Enjoyed this post?

Easily subscribe to keep get all new postings via email. No We Don't Serve Spam - Ever!

We respect your privacy

Your Comments? Tips to share?