Function Reference/get queried object
Description
Retrieve the currently-queried object. For example:
- if you're on a single post, it will return the post object
- if you're on a page, it will return the page object
- if you're on a category archive, it will return the category object
- etc.
Wrapper for $wp_query->get_queried_object().
Usage
<?php
$queried_object = get_queried_object();
var_dump( $queried_object );
?>
Parameters
None.
Return Values
- (object)
-
Examples
Notes
- Uses: WP_Query::get_queried_object
- Uses global: (object) $wp_query
Change Log
Since: 3.1.0
Source File
get_queried_object() is located in /wp-includes/query.php.
Related