Introduce "scope" query_var to be used in WP_Query
|Reported by:||wonderboymusic||Owned by:|
|Cc:||ryan@…, xoodrew@…, johnbillion, info@…, jeremy.buller@…|
After combing through a bunch of tickets, there seems to be a need for scoping queries to an initial WHERE condition.
Rather than adding an endless number of new query vars for each case, maybe we should add one query_var: scope and add cases to it.
Scope is present in Active Record in Rails: http://guides.rubyonrails.org/active_record_querying.html#scopes, which is what made me think of this.
$query = new WP_Query( array( 'post_author' => 3, 'scope' => 'has_comments' ) );
Perhaps even multiple:
$query = new WP_Query( array( 'post_author' => 3, 'scope' => 'has_comments,password_protected' ) );
$query = new WP_Query( array( 'post_author' => 3, 'scope' => array( 'has_comments', 'password_protected' ) ) );
I will add an example patch later today.