Marketing Tips, Hacks, & Cheat Sheets >>      

Genesis / StudioPress: Open Comment Author Link in New Window

May 13, 2015 Update: I just tried using this code (which I’m still using without issue on this site) on a new blog install, and it’s not working for me. Not sure why.

However, I found a plugin “Open external links in a new window” that opens internal links in the same window, while opening external links in a new tab/window. I’m using it on my foodie blog at GirlPlusFood.com without problems so far… I’m hoping to find a non-plugin solution, but this seems to work for the time being.

The comment author links in WordPress opens in the same window by default. Yeah, don’t want my readers leaving my site, so I added a code that opens the comment author links in a NEW window.

Get Paid To Do Free Offers!

Here’s the PHP code I added to my functions.php file:

  1. Access your active Genesis child theme and open the functions.php file.
  2. Copy the code snippet below and paste into the bottom of your file
Select Code
1
2
3
4
5
6
7
8
//* Make comment author link URL open in new window
add_filter( 'get_comment_author_link', 'open_comment_author_link_in_new_window' );

function open_comment_author_link_in_new_window( $author_link ) {
    
return str_replace( "<a", "<a target='_blank'", $author_link );

}

 

Genesis / StudioPress: Add Signature After Single Post
The Big List of Drop Shipping Suppliers


Tell me what you think! (Leave a comment...)

MarketingChick.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com.

Comments...

  1. Hi, Carmen.

    I copy/paste the code on my genesis function.php file, but the link yet open in same window. Are you some tip for me?

    • Hi Pablo…

      I just tried using this same code (which I’m using without issue on this MarketingChick.com site) on a new blog install… and *FAIL* I’m still not sure why it doesn’t work.

      However, I found a plugin “Open external links in a new window” (https://wordpress.org/plugins/open-external-links-in-a-new-window/) that open internal links in the same window, while external links open in a new tab/window. I’m using it on my foodie blog at GirlPlusFood.com

      I’m hoping to find a non-plugin solution, but this seems to work for the time being 🙂

      Hope that helps!

      ~ Carmen

  2. Woah! I’m really enjoying the template/theme of this
    website. It’s simple, yet effective. A lot of times it’s
    difficult to get that “perfect balance” between user friendliness and appearance.
    I must say that you’ve done a superb job with this. Additionally, the blog loads very fast for me on Opera.
    Outstanding Blog!

Leave a Comment...

*

Send this to friend