WordPress comment_author_email_link() Function

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

Definition

In WordPress, comment_author_email_link() prints a mailto link for the email address of the comment author.

It prints the link only when the comment has a real email. You can change the link text and add text before and after the link.

Syntax

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

WordPress
comment_author_email_link();
comment_author_email_link( 'Email me' );
comment_author_email_link( 'Email', '(', ')' );
CallWhat it does
comment_author_email_link()Prints the email as a link. The email is also the link text.
comment_author_email_link( 'Email me' )Prints a link with your own text.
comment_author_email_link( 'Email', '(', ')' )Adds text before and after the link.

Nothing is printed if the comment has no email address.

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

Parameters

ParameterDescription
$link_textOptional. Text to show instead of the email address.
$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 email.

WordPress Examples

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

Example 1 — Default link

Print the email as a link.

WordPress
<p><?php comment_author_email_link(); ?></p>

How It Works

  1. WordPress builds a mailto: link.
  2. The link text is the email address.
  3. If there is no email, the paragraph stays empty.

Example 3 — Text before and after

Wrap the link with your own text.

WordPress
<?php comment_author_email_link( 'Email', '[', ']' ); ?>

How It Works

  1. The second argument prints before the link.
  2. The third argument prints after the link.
  3. They print only when a link exists.

Frequently Asked Questions

It prints a mailto link for the comment author's email address.
Nothing is printed, not even the before and after text.
Yes. Pass your text as the first argument.
comment_author_email() prints plain text. comment_author_email_link() prints a clickable link.
Use get_comment_author_email_link(). It returns the HTML.

Next: comment_author_IP()

Print the IP address of the current comment author.

comment_author_IP() 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.

11 people found this page helpful