[pthumb][/pthumb]Today i am doing some checking and index updates in Google Webmaster Tools, to my surprise, there’s tons of links coming from my own site homepage url (dezzain.com) in one of my most active post – Mesocolumn WP Theme. Doing some checking and research and found out that all the links came from my own comments and reply to support thread. It is the Author Comment Website URL. Although comments website link suppose to be ‘no-follow’ but not sure if this harmful to site SEO and since i am using schema data structure on posts and comments, i really do not want any repeated links from my own homepage url.
I’m fine with other users leave their website url in comments but i would like to remove my own (Post Author) website url in comments. One of the easiest way would be go to dashboard->edit profile and remove my own website url but that’s not what i want. Continue doing some search on Google, i found a WordPress Plugin that can solved this – Disable Author and Comments Link but it does not meet my requirement since i’m still prefer commenters to leave their website url if they wanted to.
In this article, i will teach you How to Remove Post Author Website Url in Comments without WordPress Plugin, just using the WordPress core add_filter().
You just need to add this PHP Code Snippet into your [highlight color=”#111″ bgcolor=”#eee”]functions.php[/highlight]
[php]function dez_remove_post_author_weburl($return) {
global $comment, $post;
if( !is_admin() ): //only run outside dashboard
if ( $comment->user_id == $post->post_author ) {
$author = get_comment_author( get_comment_ID() );
$return = $author; //return post author display name only
return $return;
} else {
return $return; //return default
}
endif;
}
add_filter( ‘get_comment_author_link’, ‘dez_remove_post_author_weburl’);[/php]
That’s it, i used [highlight color=”#111″ bgcolor=”#eee”]is_admin()[/highlight] check to make sure the function run outside dashboard only since we still need all the default core link when editing the comments.
Hope you found this WordPress tips and tutorial useful.