WordPress comment_author_url_link() Function

Beginner
4 min read
Updated: Nov 2026
3 examples
Template tag

Definition

In WordPress, comment_author_url_link() prints the website of the commenter as a link. By default the link text is the web address.

You can change the link text and add text before and after the link. Nothing is printed when the comment has no website.

Syntax

Call it with no arguments, or set the link text and the text around it.

WordPress
comment_author_url_link();
comment_author_url_link( 'Visit site' );
comment_author_url_link( 'Visit site', '(', ')' );
CallWhat it does
comment_author_url_link()Prints the website as a link. The URL is the text.
comment_author_url_link( 'Visit site' )Prints a link with your own text.
comment_author_url_link( 'Visit', '(', ')' )Adds text before and after the link.

When you do not set the link text, WordPress shortens the URL. It removes http:// and the last slash.

Full declaration
WordPress
comment_author_url_link( string $link_text = '', string $before = '', string $after = '', int|WP_Comment $comment = 0 ): void

Parameters

ParameterDescription
$link_textOptional. Text to show instead of the URL.
$beforeOptional. Text or HTML to print before the link.
$afterOptional. Text or HTML to print after the link.
$commentOptional. A comment ID or WP_Comment object. Default is the current comment.

Return Value

Return ValueDescription
voidNothing is returned. The function prints the link, or nothing if there is no URL.

WordPress Examples

Three short theme examples. Each one has a sample output.

Example 1 — Default link

Print the website as a link.

WordPress
<p>Website: <?php comment_author_url_link(); ?></p>

How It Works

  1. WordPress builds one link from the saved URL.
  2. The URL is also the visible text.
  3. The link has rel="external".

Example 3 — Text before and after

Wrap the link with bullets.

WordPress
<?php comment_author_url_link( 'Visit site', '&bull; ', ' &bull;' ); ?>

How It Works

  1. The second argument prints before the link.
  2. The third argument prints after the link.
  3. Nothing prints at all if there is no website.

Frequently Asked Questions

It prints the comment author's website as a link.
The URL itself, without http:// and without the last slash.
Nothing is printed.
comment_author_link() links the author's name. comment_author_url_link() links the web address or text you choose.
Use get_comment_author_url_link().

Next: comment_class()

Print the class attribute with useful CSS classes for one comment.

comment_class() tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

8 people found this page helpful