Learn how to remove the author URL from WordPress comments to reduce spam and improve user experience. This beginner-friendly tutorial walks you through adding a simple code snippet to your theme’s functions.php file.
Someone leaves a comment, drops a link in the website field, and now their name is a live link pointing off your site. Sometimes that’s a real reader. A lot of the time it’s a spammer chasing a backlink. If you’d rather show the name and skip the link, one filter handles it.
Removing the Author URL from Comments
WordPress wraps the comment author’s name in a link to whatever URL they typed. The get_comment_author_link filter controls that markup, so you can hand back just the name instead.
/**
* Remove the URL from the comment author link.
*
* This function modifies the comment author link by returning only the
* author's name, without the associated URL.
*
* @param int $comment_ID The comment ID.
* @return string The comment author name without the URL.
*/
function remove_author_url( $comment_ID = 0 ) {
// Retrieve the comment object using the comment ID
$comment = get_comment( $comment_ID );
// Return only the author name without the URL
return get_comment_author( $comment );
}
// Apply the filter to modify the comment author link
add_filter( 'get_comment_author_link', 'remove_author_url' );
How It Works
The filter’s first argument is the link markup WordPress already built, not a comment ID, so the callback throws it away and returns get_comment_author() instead: the plain name, no href, no outbound link. Drop it in your theme’s functions.php or a small custom plugin and every comment author renders as text.
One note before you ship this
The real win here isn’t cosmetic. Killing the link removes the SEO incentive that drives most comment spam in the first place, so you’re treating the cause, not just the symptom. One caveat: this only cleans up get_comment_author_link. If your theme prints the URL somewhere else, for example calling get_comment_author_url directly, you’d filter comment_author_url too.


