Retrieve the currently-queried object. For example:
Note that precedence plays an important role. As an example, if you visit a custom post type archive while also passing in a taxonomy term (ie.
/my-post-type/?my_taxonomy=term), the request is both a post archive and a taxonomy archive. In this case it isn't obvious that
get_queried_object() will return the term object and not the post type object (as of WordPress 4.3). The implication is that you cannot necessarily rely on
get_queried_object() returning a post type simply because
is_post_type_archive() is true.
Wrapper for $wp_query->get_queried_object().
<?php $queried_object = get_queried_object(); var_dump( $queried_object ); ?>
get_queried_object() is located in