您提到的所有查询调用都是包装器WP_Query
(除了本身是wp\\U查询的wp\\U查询外,不需要包装器)
所以get_queried_object
指主查询和调用$wp_query->get_queried_object();
我们可以在这里找到:
http://core.trac.wordpress.org/browser/tags/3.5.1//wp-includes/query.php#L2987
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\'] );
elseif ( $query[\'terms\'] )
$term = get_term_by( $query[\'field\'], reset( $query[\'terms\'] ), $query[\'taxonomy\'] );
if ( ! empty( $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_post( $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;
}
所以传入的参数和循环的迭代次数是决定因素。
TDLR:只要遵循代码,大多数IDE都有一个跳转到定义按钮,可以直接将您带到那里