Changeset 16844 for trunk/wp-includes/query.php
- Timestamp:
- 12/09/2010 05:09:42 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/query.php
r16843 r16844 1940 1940 1941 1941 // Taxonomies 1942 if ( !$this->is_singular) {1942 if ( $this->is_category || $this->is_tag || $this->is_tax ) { 1943 1943 $this->tax_query = $this->parse_tax_query( $q ); 1944 1944 1945 if ( ! empty( $this->tax_query ) ) { 1946 $clauses = call_user_func_array( 'get_tax_sql', array( $this->tax_query, $wpdb->posts, 'ID', &$this) ); 1947 1948 $join .= $clauses['join']; 1949 $where .= $clauses['where']; 1950 1951 if ( $this->is_tax ) { 1952 if ( empty($post_type) ) { 1953 $post_type = 'any'; 1954 $post_status_join = true; 1955 } elseif ( in_array('attachment', (array) $post_type) ) { 1956 $post_status_join = true; 1957 } 1945 $clauses = call_user_func_array( 'get_tax_sql', array( $this->tax_query, $wpdb->posts, 'ID', &$this) ); 1946 1947 $join .= $clauses['join']; 1948 $where .= $clauses['where']; 1949 1950 if ( $this->is_tax ) { 1951 if ( empty($post_type) ) { 1952 $post_type = 'any'; 1953 $post_status_join = true; 1954 } elseif ( in_array('attachment', (array) $post_type) ) { 1955 $post_status_join = true; 1958 1956 } 1959 1960 // Back-compat 1961 $tax_query_in = wp_list_filter( $this->tax_query, array( 'operator' => 'IN' ) ); 1962 if ( !empty( $tax_query_in ) ) { 1963 if ( !isset( $q['taxonomy'] ) ) { 1964 foreach ( $tax_query_in as $a_tax_query ) { 1965 if ( !in_array( $a_tax_query['taxonomy'], array( 'category', 'post_tag' ) ) ) { 1966 $q['taxonomy'] = $a_tax_query['taxonomy']; 1967 if ( 'slug' == $a_tax_query['field'] ) 1968 $q['term'] = $a_tax_query['terms'][0]; 1969 else 1970 $q['term_id'] = $a_tax_query['terms'][0]; 1971 1972 break; 1973 } 1974 } 1975 } 1976 1977 $cat_query = wp_list_filter( $tax_query_in, array( 'taxonomy' => 'category' ) ); 1978 if ( !empty( $cat_query ) ) { 1979 $cat_query = reset( $cat_query ); 1980 $cat = get_term_by( $cat_query['field'], $cat_query['terms'][0], 'category' ); 1981 if ( $cat ) { 1982 $this->set( 'cat', $cat->term_id ); 1983 $this->set( 'category_name', $cat->slug ); 1957 } 1958 1959 // Back-compat 1960 $tax_query_in = wp_list_filter( $this->tax_query, array( 'operator' => 'IN' ) ); 1961 if ( !empty( $tax_query_in ) ) { 1962 if ( !isset( $q['taxonomy'] ) ) { 1963 foreach ( $tax_query_in as $a_tax_query ) { 1964 if ( !in_array( $a_tax_query['taxonomy'], array( 'category', 'post_tag' ) ) ) { 1965 $q['taxonomy'] = $a_tax_query['taxonomy']; 1966 if ( 'slug' == $a_tax_query['field'] ) 1967 $q['term'] = $a_tax_query['terms'][0]; 1968 else 1969 $q['term_id'] = $a_tax_query['terms'][0]; 1970 1971 break; 1984 1972 } 1985 1973 } 1986 1974 } 1987 } 1988 } 1989 1990 if ( !empty( $this->tax_query ) || !empty( $q['meta_key'] ) ) { 1975 1976 $cat_query = wp_list_filter( $tax_query_in, array( 'taxonomy' => 'category' ) ); 1977 if ( !empty( $cat_query ) ) { 1978 $cat_query = reset( $cat_query ); 1979 $cat = get_term_by( $cat_query['field'], $cat_query['terms'][0], 'category' ); 1980 if ( $cat ) { 1981 $this->set( 'cat', $cat->term_id ); 1982 $this->set( 'category_name', $cat->slug ); 1983 } 1984 } 1985 } 1986 } 1987 1988 if ( $this->is_category || $this->is_tag || $this->is_tax || !empty( $q['meta_key'] ) ) { 1991 1989 $groupby = "{$wpdb->posts}.ID"; 1992 1990 }
Note: See TracChangeset
for help on using the changeset viewer.