get_the_ID
Retrieve the ID of the current item in the WordPress Loop.
Description
(int|false) get_the_ID();
Returns (int|false)
The ID of the current item in the WordPress Loop. False if $post is not set.
Usage
if ( !function_exists( 'get_the_ID' ) ) { require_once ABSPATH . WPINC . '/post-template.php'; } // NOTICE! Understand what this does before running. $result = get_the_ID();
Defined (1)
The function is defined in the following location(s).
- /wp-includes/post-template.php
- function get_the_ID() {
- $post = get_post();
- return ! empty( $post ) ? $post->ID : false;
- }