comment_author_email_link()
Outputs the email address of the commenter as a mailto link.
If the option to require filling in the name and email is disabled in the settings, then comment_author_email_link() will not output anything.
This tag should be used inside the Comments Loop.
Note: displaying email addresses is not safe, as they can be used by spammers.
No Hooks.
Returns
null. Outputs the html code for the mailto link.
Usage
<?php comment_author_email_link($linktext, $before, $after); ?>
- $linktext(string)
- Text of the link. By default, the email of the commenter is displayed.
Default: commenter's email - $before(string)
- Text before the link.
Default: '' - $after(string)
- Text after the link.
Default: '' - $comment(int/WP_Comment)
- ID or object of the comment, the email link of whose author needs to be obtained. Since version 4.6.
Default: 0 (current comment)
Examples
#1 Display the commenter's email:
email: <?php comment_author_email_link(); ?><br />
#2 Change the link text
To "Write a commenter to e-mail" and highlight it first and end with [ and ]:
<?php comment_author_email_link( 'Write a commenter to mail', ' [ ', ' ] '); ?>
Get this: [ <a href="mailto:[email protected]">Write to commenter</a> ]
Changelog
| Since 0.71 | Introduced. |
| Since 4.6.0 | Added the $comment parameter. |
comment_author_email_link() comment author email link code WP 6.9
function comment_author_email_link( $link_text = '', $before = '', $after = '', $comment = null ) {
$link = get_comment_author_email_link( $link_text, $before, $after, $comment );
if ( $link ) {
echo $link;
}
}