get_the_ID() WordPress Function
The get_the_ID() function is used to retrieve the post ID of the current post. This function can be used within the loop to return the post ID of the post being processed.
get_the_ID() #
Retrieves the ID of the current item in the WordPress Loop.
Return
(int|false) The ID of the current item in the WordPress Loop. False if $post is not set.
Source
File: wp-includes/post-template.php
function get_the_ID() { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName.FunctionNameInvalid $post = get_post(); return ! empty( $post ) ? $post->ID : false; }
Expand full source codeCollapse full source codeView on TracView on GitHub
Changelog
Version | Description |
---|---|
2.1.0 | Introduced. |