Title: comment_ID
Published: April 25, 2014
Last modified: April 28, 2025

---

# comment_ID()

## In this article

 * [Source](https://developer.wordpress.org/reference/functions/comment_id/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/functions/comment_id/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/functions/comment_id/?output_format=md#changelog)
 * [User Contributed Notes](https://developer.wordpress.org/reference/functions/comment_id/?output_format=md#user-contributed-notes)

[ Back to top](https://developer.wordpress.org/reference/functions/comment_id/?output_format=md#wp--skip-link--target)

Displays the comment ID of the current comment.

## 󠀁[Source](https://developer.wordpress.org/reference/functions/comment_id/?output_format=md#source)󠁿

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

[View all references](https://developer.wordpress.org/reference/files/wp-includes/comment-template.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/6.9.4/src/wp-includes/comment-template.php#L749)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/6.9.4/src/wp-includes/comment-template.php#L749-L751)

## 󠀁[Related](https://developer.wordpress.org/reference/functions/comment_id/?output_format=md#related)󠁿

| Uses | Description | 
| [get_comment_ID()](https://developer.wordpress.org/reference/functions/get_comment_id/)`wp-includes/comment-template.php` |

Retrieves the comment ID of the current comment.

  |

| Used by | Description | 
| [Walker_Comment::comment()](https://developer.wordpress.org/reference/classes/walker_comment/comment/)`wp-includes/class-walker-comment.php` |

Outputs a single comment.

  | 
| [Walker_Comment::html5_comment()](https://developer.wordpress.org/reference/classes/walker_comment/html5_comment/)`wp-includes/class-walker-comment.php` |

Outputs a comment in the HTML5 format.

  | 
| [Walker_Comment::ping()](https://developer.wordpress.org/reference/classes/walker_comment/ping/)`wp-includes/class-walker-comment.php` |

Outputs a pingback comment.

  |

## 󠀁[Changelog](https://developer.wordpress.org/reference/functions/comment_id/?output_format=md#changelog)󠁿

| Version | Description | 
| [0.71](https://developer.wordpress.org/reference/since/0.71/) | Introduced. |

## 󠀁[User Contributed Notes](https://developer.wordpress.org/reference/functions/comment_id/?output_format=md#user-contributed-notes)󠁿

 1.  [Skip to note 2 content](https://developer.wordpress.org/reference/functions/comment_id/?output_format=md#comment-content-1367)
 2.   [Codex](https://profiles.wordpress.org/codex/)  [  10 years ago  ](https://developer.wordpress.org/reference/functions/comment_id/#comment-1367)
 3. [You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fcomment_id%2F%23comment-1367)
    Vote results for this note: 1[You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fcomment_id%2F%23comment-1367)
 4. **Comment ID as Anchor ID**
 5. Uses the comment ID as an anchor id for a comment.
 6.     ```php
        <div id="comment-<?php comment_ID() ?>">Comment by 
        <?php comment_author() ?>: </div>
        <div class="comment-text"><?php comment_text() ?></div>
        ```
    
 7.  [Log in to add feedback](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fcomment_id%2F%3Freplytocom%3D1367%23feedback-editor-1367)

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fcomment_id%2F)
before being able to contribute a note or feedback.