get_queried_object() returns null on post date archive

so my question is, is this intended functionality (e.g. are you not
supposed to use get_queried_object() on those pages), a technical
limitation (is there not a meaningful object to return on those
pages), or simply an implementation oversight?

get_queried_object() is to get the term, author, single post, single custom post type, or page object being queried. Yes this is intentional and what this function was designed to do.

If you are on a date archive, home page, or search there is no single object being queried.

Edit:

Based on the first comment below the OP needs to get the post_type object. The post_type object is different from the queried_object. If you need to get the post_type object on an archive page you can get it from the query_vars.

global $wp_query;

$post_type_object = get_post_type_object( $wp_query->query_vars['post_type'] );

Leave a Comment