When viewing a Parent term in a hierarchical taxonomy, display objects contained within children too. Props scribu. Fixes #12533
git-svn-id: http://svn.automattic.com/wordpress/trunk@13787 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
68445ab030
commit
e2a7385be8
|
@ -1996,23 +1996,29 @@ class WP_Query {
|
|||
if ( '' != $q['taxonomy'] ) {
|
||||
$taxonomy = $q['taxonomy'];
|
||||
$tt[$taxonomy] = $q['term'];
|
||||
$terms = get_terms($q['taxonomy'], array('slug'=>$q['term']));
|
||||
} else {
|
||||
foreach ( $GLOBALS['wp_taxonomies'] as $taxonomy => $t ) {
|
||||
if ( $t->query_var && '' != $q[$t->query_var] ) {
|
||||
$terms = get_terms($taxonomy, array('slug'=>$q[$t->query_var]));
|
||||
if ( !is_wp_error($terms) )
|
||||
$tt[$taxonomy] = $q[$t->query_var];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$terms = get_terms($taxonomy, array('slug' => $tt[$taxonomy], 'hide_empty' => !is_taxonomy_hierarchical($taxonomy)));
|
||||
|
||||
if ( is_wp_error($terms) || empty($terms) ) {
|
||||
$whichcat = " AND 0 ";
|
||||
} else {
|
||||
foreach ( $terms as $term )
|
||||
foreach ( $terms as $term ) {
|
||||
$term_ids[] = $term->term_id;
|
||||
if ( is_taxonomy_hierarchical($taxonomy) ) {
|
||||
$children = get_term_children($term->term_id, $taxonomy);
|
||||
$term_ids = array_merge($term_ids, $children);
|
||||
}
|
||||
}
|
||||
$post_ids = get_objects_in_term($term_ids, $taxonomy);
|
||||
if ( !is_wp_error($post_ids) && count($post_ids) ) {
|
||||
if ( !is_wp_error($post_ids) && !empty($post_ids) ) {
|
||||
$whichcat .= " AND $wpdb->posts.ID IN (" . implode(', ', $post_ids) . ") ";
|
||||
$post_type = 'any';
|
||||
$q['post_status'] = 'publish';
|
||||
|
@ -2826,5 +2832,4 @@ function setup_postdata($post) {
|
|||
|
||||
return true;
|
||||
}
|
||||
|
||||
?>
|
Loading…
Reference in New Issue