category__and, tag__and, tag_slug__in, tag_slug__and support. fixes #16157

git-svn-id: https://develop.svn.wordpress.org/trunk@17244 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Ryan Boren
2011-01-09 16:19:48 +00:00
parent 91352574d7
commit f59c869e62
2 changed files with 63 additions and 8 deletions

View File

@@ -1692,7 +1692,7 @@ class WP_Query {
}
if ( !empty($q['category__in']) ) {
$q['category__in'] = array_unique( $q['category__in'] );
$q['category__in'] = array_map('absint', array_unique( $q['category__in'] ) );
$tax_query[] = array(
'taxonomy' => 'category',
'terms' => $q['category__in'],
@@ -1701,34 +1701,75 @@ class WP_Query {
}
if ( !empty($q['category__not_in']) ) {
$q['category__not_in'] = array_unique( $q['category__not_in'] );
$q['category__not_in'] = array_map('absint', array_unique( $q['category__not_in'] ) );
$tax_query[] = array(
'taxonomy' => 'category',
'terms' => $q['category__not_in'],
'operator' => 'NOT IN',
'operator' => 'NOT IN'
);
}
if ( !empty($q['category__and']) ) {
$q['category__and'] = array_map('absint', array_unique( $q['category__and'] ) );
$tax_query[] = array(
'taxonomy' => 'category',
'terms' => $q['category__and'],
'field' => 'term_id',
'operator' => 'AND'
);
}
// Tag stuff
if ( !empty($q['tag_id']) ) {
$q['tag_id'] = absint( $q['tag_id'] );
$tax_query[] = array(
'taxonomy' => 'post_tag',
'terms' => $q['tag_id'],
'terms' => $q['tag_id']
);
}
if ( !empty($q['tag__in']) ) {
$q['tag__in'] = array_map('absint', array_unique( $q['tag__in'] ) );
$tax_query[] = array(
'taxonomy' => 'post_tag',
'terms' => $q['tag__in'],
'terms' => $q['tag__in']
);
}
if ( !empty($q['tag__not_in']) ) {
$q['tag__not_in'] = array_map('absint', array_unique( $q['tag__not_in'] ) );
$tax_query[] = array(
'taxonomy' => 'post_tag',
'terms' => $q['tag__not_in'],
'operator' => 'NOT IN',
'operator' => 'NOT IN'
);
}
if ( !empty($q['tag__and']) ) {
$q['tag__and'] = array_map('absint', array_unique( $q['tag__and'] ) );
$tax_query[] = array(
'taxonomy' => 'post_tag',
'terms' => $q['tag__and'],
'operator' => 'AND'
);
}
if ( !empty($q['tag_slug__in']) ) {
$q['tag_slug__in'] = array_map('sanitize_title', $q['tag_slug__in']);
$tax_query[] = array(
'taxonomy' => 'post_tag',
'terms' => $q['tag_slug__in'],
'field' => 'slug'
);
}
if ( !empty($q['tag_slug__and']) ) {
$q['tag_slug__and'] = array_map('sanitize_title', $q['tag_slug__and']);
$tax_query[] = array(
'taxonomy' => 'post_tag',
'terms' => $q['tag_slug__and'],
'field' => 'slug',
'operator' => 'AND'
);
}