[wp-hackers] Accessing custom post types and taxonomies across sites on a network

Cornelius, Gregory gcorne at bu.edu
Mon Jan 24 22:45:08 UTC 2011


> 
> Back to your question, I suppose I could just define the taxonomy in
> mu-plugins. But, then it would be defined in a lot of sites that would
> not need it. Too much overhead?


After looking at your initial code again and WP_Query, I suspect that if you specify the term *and* the taxonomy, the fact that the taxonomy is not registered will not matter.

$args = array (
'post_type' => 'faculty_profile',
'orderby' => 'meta_value',
'meta_key' => 'sortby',
'order' => 'ASC',
'posts_per_page' => -1,
'taxonomy' => 'departments',
'term' => 'economics'
);

Note: I am not sure whether this is the intended behavior or not. Looking at 3.1-RC3 this is changed for some reason.

##3.0.4

if ( $this->is_tax ) {
                        if ( '' != $q['taxonomy'] ) {
                                $taxonomy = $q['taxonomy'];
                                $tt[$taxonomy] = $q['term'];
                        } else {
                                foreach ( $GLOBALS['wp_taxonomies'] as $taxonomy => $t ) {
				//stuff
				}
			}
}

## ---

# 3.1-RC3 

              if ( !empty($q['taxonomy']) && !empty($q['term']) ) {
			$tax_query[] = array(
				'taxonomy' => $q['taxonomy'],
				'terms' => array( $q['term'] ),
				'field' => 'slug',
			);
		}

		foreach ( $GLOBALS['wp_taxonomies'] as $taxonomy => $t ) {
			if ( $t->query_var && !empty( $q[$t->query_var] ) ) {
				$tax_query_defaults = array(
					'taxonomy' => $taxonomy,
					'field' => 'slug',
				); 
		



More information about the wp-hackers mailing list