Example 1 — Default link
Print the website as a link.
<p>Website: <?php comment_author_url_link(); ?></p> How It Works
- WordPress builds one link from the saved URL.
- The URL is also the visible text.
- The link has
rel="external".

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.
Call it with no arguments, or set the link text and the text around it.
comment_author_url_link();
comment_author_url_link( 'Visit site' );
comment_author_url_link( 'Visit site', '(', ')' ); | Call | What 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.
comment_author_url_link( string $link_text = '', string $before = '', string $after = '', int|WP_Comment $comment = 0 ): void | Parameter | Description |
|---|---|
$link_text | Optional. Text to show instead of the URL. |
$before | Optional. Text or HTML to print before the link. |
$after | Optional. Text or HTML to print after the link. |
$comment | Optional. A comment ID or WP_Comment object. Default is the current comment. |
| Return Value | Description |
|---|---|
| void | Nothing is returned. The function prints the link, or nothing if there is no URL. |
Three short theme examples. Each one has a sample output.
Print the website as a link.
<p>Website: <?php comment_author_url_link(); ?></p> rel="external".Use friendly text for the link.
<?php comment_author_url_link( 'Visit website' ); ?> href stays the same.Wrap the link with bullets.
<?php comment_author_url_link( 'Visit site', '• ', ' •' ); ?> Print the class attribute with useful CSS classes for one comment.
8 people found this page helpful