Title: the_ID
Published: April 25, 2014
Last modified: February 24, 2026

---

# the_ID()

## In this article

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

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

Displays the ID of the current item in the WordPress Loop.

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

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

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

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

| Uses | Description | 
| [get_the_ID()](https://developer.wordpress.org/reference/functions/get_the_id/)`wp-includes/post-template.php` |

Retrieves the ID of the current item in the WordPress Loop.

  |

| Used by | Description | 
| [WP_Posts_List_Table::column_cb()](https://developer.wordpress.org/reference/classes/wp_posts_list_table/column_cb/)`wp-admin/includes/class-wp-posts-list-table.php` |

Handles the checkbox column output.

  |

## 󠀁[Changelog](https://developer.wordpress.org/reference/functions/the_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/the_id/?output_format=md#user-contributed-notes)󠁿

 1.   [Skip to note 3 content](https://developer.wordpress.org/reference/functions/the_id/?output_format=md#comment-content-560)
 2.    [Codex](https://profiles.wordpress.org/codex/)  [  11 years ago  ](https://developer.wordpress.org/reference/functions/the_id/#comment-560)
 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%2Fthe_id%2F%23comment-560)
     Vote results for this note: 0[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%2Fthe_id%2F%23comment-560)
 4.  Default usage.
 5.      ```php
         <p>Post Number: <?php the_ID(); ?></p>
         ```
     
 6.   [Log in to add feedback](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fthe_id%2F%3Freplytocom%3D560%23feedback-editor-560)
 7.   [Skip to note 4 content](https://developer.wordpress.org/reference/functions/the_id/?output_format=md#comment-content-561)
 8.    [Codex](https://profiles.wordpress.org/codex/)  [  11 years ago  ](https://developer.wordpress.org/reference/functions/the_id/#comment-561)
 9.  [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%2Fthe_id%2F%23comment-561)
     Vote results for this note: 0[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%2Fthe_id%2F%23comment-561)
 10. This example shows how to provide a unique anchor identifier to each post.
 11.     ```php
         <h3 id="post-<?php the_ID(); ?>"><?php the_title(); ?></h3>
         ```
     
 12.  [Log in to add feedback](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fthe_id%2F%3Freplytocom%3D561%23feedback-editor-561)

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