WP_Query::get_queried_object_id()publicWP 1.5.0

Retrieves the ID of the currently queried object.

Method of the class: WP_Query{}

No Hooks.

Return

Int.

Usage

global $wp_query;
$wp_query->get_queried_object_id();

Changelog

Since 1.5.0 Introduced.

WP_Query::get_queried_object_id() code WP 6.5.2

public function get_queried_object_id() {
	$this->get_queried_object();

	if ( isset( $this->queried_object_id ) ) {
		return $this->queried_object_id;
	}

	return 0;
}