Definition:
function get_queried_object() {}
Retrieve the currently-queried object. Wrapper for $wp_query->get_queried_object()
Source code
function get_queried_object() {
if ( isset($this->queried_object) )
return $this->queried_object;
$this->queried_object = NULL;
$this->queried_object_id = 0;
if ( $this->is_category || $this->is_tag || $this->is_tax ) {
$tax_query_in_and = wp_list_filter( $this->tax_query->queries, array( 'operator' => 'NOT IN' ), 'NOT' );
$query = reset( $tax_query_in_and );
if ( 'term_id' == $query['field'] )
$term = get_term( reset( $query['terms'] ), $query['taxonomy'] );
else
$term = get_term_by( $query['field'], reset( $query['terms'] ), $query['taxonomy'] );
if ( $term && ! is_wp_error($term) ) {
$this->queried_object = $term;
$this->queried_object_id = (int) $term->term_id;
if ( $this->is_category )
_make_cat_compat( $this->queried_object );
}
} elseif ( $this->is_post_type_archive ) {
$this->queried_object = get_post_type_object( $this->get('post_type') );
} elseif ( $this->is_posts_page ) {
$page_for_posts = get_option('page_for_posts');
$this->queried_object = & get_page( $page_for_posts );
$this->queried_object_id = (int) $this->queried_object->ID;
} elseif ( $this->is_singular && !is_null($this->post) ) {
$this->queried_object = $this->post;
$this->queried_object_id = (int) $this->post->ID;
} elseif ( $this->is_author ) {
$this->queried_object_id = (int) $this->get('author');
$this->queried_object = get_userdata( $this->queried_object_id );
}
return $this->queried_object;
}
9627

February 24, 2011 


No comments yet... Be the first to leave a reply!