WordPress.org

Ready to get started?Download WordPress

Codex

Attention Interested in functions, hooks, classes, or methods? Check out the new WordPress Code Reference!

Function Reference/get queried object

Contents

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
  • if you're on an author archive, it will return the author 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