WordPress at a glance

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.


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


<?php comment_ID(); ?>


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


Since 0.71 Introduced.

Code of comment_ID() WP 5.7.2

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

From category: Comments Loop

More from Template Tags: Comments

No comments
    Log In