WP_Query::get_queried_object_id() WordPress Method

The WP_Query::get_queried_object_id() method is used to get the current post, page, or custom post type ID.

WP_Query::get_queried_object_id() #

Retrieves the ID of the currently queried object.


Return

(int)


Top ↑

Source

File: wp-includes/class-wp-query.php

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

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

		return 0;
	}


Top ↑

Changelog

Changelog
VersionDescription
1.5.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.

Show More