get_queried_object_id() WordPress Function

The get_queried_object_id() function is used to get the current object ID. This can be useful when you need to know the ID of the current object, such as when you need to get the ID of the current post.

get_queried_object_id() #

Retrieves the ID of the currently queried object.


Description

Wrapper for WP_Query::get_queried_object_id().


Top ↑

Return

(int) ID of the queried object.


Top ↑

Source

File: wp-includes/query.php

function get_queried_object_id() {
	global $wp_query;
	return $wp_query->get_queried_object_id();
}


Top ↑

Changelog

Changelog
VersionDescription
3.1.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.