comment_ID() WP 0.71
Displays the ID of the current comment. Uses in a comments loop.
Works based on: get_comment_ID()
No Hooks.
Return
Nothing (null). Displays the result of the get_comment_ID() function.
Usage
<?php comment_ID(); ?>
Examples
#1. Get the link with anchor text on the comment
With text which is the name of the commentator. The code should be used in a comment loop:
<div id="comment-<?php comment_ID() ?>">Comment by <?php comment_author() ?>: </div> <div class="comment-text"><?php comment_text() ?></div>
Changelog
Since 0.71 | Introduced. |
Code of comment_ID() comment ID WP 5.6
function comment_ID() { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName.FunctionNameInvalid
echo get_comment_ID();
}Related Functions
From category: Comments Loop
- comment_author()
- comment_author_email()
- comment_author_link()
- comment_author_url()
- comment_author_url_link()
- comment_class()
- comment_date()