comment_ID()WP 0.71

Displays the ID of the current comment. Uses in a comments loop.

No Hooks.

Return

null. Nothing (null). Displays the result of the get_comment_ID() function.

Usage

<?php comment_ID(); ?>

Examples

0

#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.

comment_ID() code WP 6.6.2

function comment_ID() { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName.FunctionNameInvalid
	echo get_comment_ID();
}