From 89382ae3130367f93f49ebf4a21ea9578d7fad01 Mon Sep 17 00:00:00 2001 From: scribu Date: Fri, 17 Sep 2010 16:08:35 +0000 Subject: [PATCH] Allow plugins to manipulate the meta query args. See #14645 git-svn-id: https://develop.svn.wordpress.org/trunk@15624 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-includes/query.php | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/wp-includes/query.php b/wp-includes/query.php index db1deef561..99d43a1a7a 100644 --- a/wp-includes/query.php +++ b/wp-includes/query.php @@ -670,6 +670,15 @@ class WP_Query { */ var $tax_query = array(); + /** + * Metadata query + * + * @since 3.1.0 + * @access public + * @var array + */ + var $meta_query = array(); + /** * Holds the data for a single object that is queried. * @@ -1363,6 +1372,10 @@ class WP_Query { $this->is_tax = true; } + $meta_query = wp_array_slice_assoc( $qv, array( 'meta_key', 'meta_value', 'meta_compare' ) ); + if ( !empty( $meta_query ) ) + $this->meta_query[] = $meta_query; + if ( empty($qv['author']) || ($qv['author'] == '0') ) { $this->is_author = false; } else { @@ -2166,9 +2179,7 @@ class WP_Query { $where .= ')'; } - // postmeta queries - $meta_query = wp_array_slice_assoc( $q, array( 'meta_key', 'meta_value', 'meta_compare' ) ); - list( $meta_join, $meta_where ) = _wp_meta_sql( array( $meta_query ), $wpdb->posts, 'ID', $wpdb->postmeta, 'post_id' ); + list( $meta_join, $meta_where ) = _wp_meta_sql( $this->meta_query, $wpdb->posts, 'ID', $wpdb->postmeta, 'post_id' ); $join .= $meta_join; $where .= $meta_where;