WordPress.org

Codex

Interested in functions, hooks, classes, or methods? Check out the new WordPress Code Reference!

Function Reference/comment ID

Description

Displays the numeric ID of the current comment. This tag must be within The Loop, or a comment loop.

Use get_comment_ID to retrieve the value.

Usage

 <?php comment_ID(); ?> 

Parameters

This function does not accept parameters

Return Values

see get_comment_ID() for Echoes Result

Examples

Default Usage

<p>This is comment <?php comment_ID(); ?> for all comments.</p>

Comment ID as Anchor ID

Uses the comment ID as an anchor id for a comment.

<div id="comment-<?php comment_ID() ?>">Comment by 
<?php comment_author() ?>: </div>
<div class="comment-text"><?php comment_text() ?></div>

Notes

Change Log

Since: 1.5.0

Source File

comment_ID() is located in wp-includes/comment-template.php

Related

Comments Functions

See also index of Function Reference and index of Template Tags.