In the wordpress 2.5 and above versions, comments author URL opens up in the same window. This could possibly make your blog reader to get away to other sites. If you want it to be opened up in new window, you need to make the following code changes.
Look for this file : ../wp-includes/comment-template.php and take a look at the piece of code which is mentioned as below.
function get_comment_author_link() {
$url = get_comment_author_url();
$author = get_comment_author();
if ( empty( $url ) || 'http://' == $url )
$return = $author;
else
$return = "<a href='$url' rel='external nofollow'>$author</a>";
return apply_filters('get_comment_author_link', $return);
}
Modify the above block of code with changes as shown below.
function get_comment_author_link() {
$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 apply_filters('get_comment_author_link', $return);
}
Thats it. You are done! Enjoy the wordpress while retaining traffic on your site π
Neeta says
With great content the visitor to the site will stay and wll not bother about opening in the new window or the existing window.
Nik says
Nope, it doesn’t work, since WP3.0. Any ideas?
Mohan says
How come? I have changed it on WP 3.0 on this blog and it is working!!! you can test it out yourself π
Nik says
Nope, it doesn’t work, since WP3.0. Any ideas?
Mohan says
How come? I have changed it on WP 3.0 on this blog and it is working!!! you can test it out yourself π
Vishal says
Thanks a lot for this info Mohan…was looking to change it for a while now…will do it right away π
Vishal says
Thanks a lot for this info Mohan…was looking to change it for a while now…will do it right away π
Mohan says
Awesome! Glad it was useful for you π
AnandK says
Nice – I will try it out; I was looking for a way to do it ! π
Mohan says
Great! all the best π
dave joneja says
Useful information.
I am so inspired by Randy Pausch’s video. Thank you!
Mohan says
Glad you liked it!
dave joneja says
Useful information.
I am so inspired by Randy Pausch’s video. Thank you!
Mohan says
Glad you liked it!
zachary says
doesn’t this get over-written when you upgrade WP?
Mohan says
Hi Zachary, you are right. the above mentioned method will be overwritten whenever WP is upgraded.
Ricci says
THANK YOU! I spent way too much time yesterday looking for this in the template files and even in the includes. How I missed comment-template (duh), I’ll never know. You rock. – Ricci
Mohan says
Hi Ricci, I am glad that my post was helpful to you.
Ricci says
THANK YOU! I spent way too much time yesterday looking for this in the template files and even in the includes. How I missed comment-template (duh), I’ll never know. You rock. – Ricci
Mohan says
Hi Ricci, I am glad that my post was helpful to you.
Alexwebmaster says
Hello webmaster
I would like to share with you a link to your site
Alexwebmaster says
Hello webmaster
I would like to share with you a link to your site
Melinda says
Thank you so much, this has been driving me crazy. I tried some other things that didn’t work. I would much rather do this than install yet another plugin to do something that turned out to be so simple.
Melinda says
Thank you so much, this has been driving me crazy. I tried some other things that didn’t work. I would much rather do this than install yet another plugin to do something that turned out to be so simple.
boomzefenue says
fascinating and educational, but would participate in something more on this topic?
boomzefenue says
fascinating and educational, but would participate in something more on this topic?
Mohan says
@JK
Yeah, plugins do the same job of over riding certain piece of native code. It is always better to get it done through simple solutions like this than having plugins. I am glad that was useful for you.
JK says
Mohan, Thanks for your post. I saw a few plugins to do this but your solution is far more simple. Great job!
JK says
Mohan, Thanks for your post. I saw a few plugins to do this but your solution is far more simple. Great job!
Mohan says
@Shirley
Thanks for pointing me to a different way of doing it. yes, I agree with you.. Editing on theme’s functions.php is a safer way of accomplishing this task.
Mohan says
@Shirley
Thanks for pointing me to a different way of doing it. yes, I agree with you.. Editing on theme’s functions.php is a safer way of accomplishing this task.
Shirley says
You could use a filter in your theme’s functions.php file to accomplish the same thing. It’s a better approach because you don’t have to edit the code and risk making fatal changes. Additionally, if this is part of your theme, it stays with you when you upgrade… Just a thought.
Shirley says
You could use a filter in your theme’s functions.php file to accomplish the same thing. It’s a better approach because you don’t have to edit the code and risk making fatal changes. Additionally, if this is part of your theme, it stays with you when you upgrade… Just a thought.
Mohan says
Hi RAG, Why not! Sure, I will write up a post on creating own blogs some time very soon. You gave me a topic to write up my next article.. Cheers!
Mohan says
Hi RAG, Why not! Sure, I will write up a post on creating own blogs some time very soon. You gave me a topic to write up my next article.. Cheers!
RAG says
Hi Mohan,
Can you please write up a post on “How to create own blog”?
I know there are some free blogs available like blogspot, but URL of these are not attractive.
I also comes from IT field but have no idea bout php. But i have liitle knowledge about html.
RAG says
Hi Mohan,
Can you please write up a post on “How to create own blog”?
I know there are some free blogs available like blogspot, but URL of these are not attractive.
I also comes from IT field but have no idea bout php. But i have liitle knowledge about html.
Mohan says
Hi Danny, I am glad that my post helped someone like you. Feel free to post back for any help you may require wrt WordPress customization.
Mohan says
Hi Danny, I am glad that my post helped someone like you. Feel free to post back for any help you may require wrt WordPress customization.
Danny says
Simple but brilliant!
Many thanks, Mohan. I know it had to be something as simple as this but I am not a PHP coder and just did not know where to start looking.
Best wishes,
Danny
Danny says
Simple but brilliant!
Many thanks, Mohan. I know it had to be something as simple as this but I am not a PHP coder and just did not know where to start looking.
Best wishes,
Danny