WordPress at Your Fingertips

get_queried_object() WP 1.0

Retrieve the currently-queried object.

Wrapper for WP_Query::get_queried_object().

1 time — 0.000026 sec (very fast) | 50000 times — 0.06 sec (speed of light)

No Hooks.

Return

WP_Term|WP_Post_Type|WP_Post|WP_User|null. The queried object.

Usage

get_queried_object();

Notes

  • Global. WP_Query. $wp_query WordPress Query object.

Changelog

Since 3.1.0 Introduced.

Code of get_queried_object() WP 5.8.1

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

query

Main Query

No comments
    Log In