Example 1 — Print the URL
Print the website as text.
<p>Website: <?php comment_author_url(); ?></p> How It Works
- The function prints the saved URL.
- It prints text only, not a link.
- The URL is already cleaned by WordPress.

In WordPress, comment_author_url() prints the website address that the commenter typed in the form.
It prints only the URL text. It does not build a link. Use it inside an href or when you need the address by itself.
Call it inside the comment loop, or pass a comment ID.
comment_author_url();
comment_author_url( 15 ); | Call | What it does |
|---|---|
comment_author_url() | Prints the website URL of the current comment author. |
comment_author_url( 15 ) | Prints the URL for comment 15. |
get_comment_author_url() | Returns the URL instead of printing it. |
If the commenter left the website empty, nothing is printed.
comment_author_url( int|WP_Comment $comment_id = 0 ): void | Parameter | Description |
|---|---|
$comment_id | Optional. A comment ID or a WP_Comment object. Default 0, which means the current comment. |
| Return Value | Description |
|---|---|
| void | Nothing is returned. The function prints the URL. |
Three short theme examples. Each one has a sample output.
Print the website as text.
<p>Website: <?php comment_author_url(); ?></p> Build your own link with the URL.
<a href="<?php comment_author_url(); ?>" rel="nofollow ugc">Visit site</a> href.rel="nofollow ugc" is added by you.Show the link only if there is a URL.
<?php if ( get_comment_author_url() ) : ?>
<a href="<?php comment_author_url(); ?>" rel="nofollow ugc">Website</a>
<?php endif; ?> get_comment_author_url() returns the URL or an empty string.Print the commenter's website as a clickable link.
15 people found this page helpful