get_objects_in_term(): include term children when querying by slug. See #12891
git-svn-id: http://svn.automattic.com/wordpress/trunk@15654 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
248b086540
commit
d4ded42a1b
|
@ -471,19 +471,28 @@ function get_objects_in_term( $terms, $taxonomies, $args = array() ) {
|
||||||
if ( !in_array( $operator, array( 'IN', 'NOT IN' ) ) )
|
if ( !in_array( $operator, array( 'IN', 'NOT IN' ) ) )
|
||||||
$operator = 'IN';
|
$operator = 'IN';
|
||||||
|
|
||||||
|
if ( is_taxonomy_hierarchical( $taxonomy ) && $include_children ) {
|
||||||
|
$children = array();
|
||||||
|
foreach ( $terms as $term ) {
|
||||||
|
if ( 'term_id' != $field ) {
|
||||||
|
if ( $term = get_term_by( $field, $term, $taxonomy ) )
|
||||||
|
$term = $term->term_id;
|
||||||
|
else
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
$children = array_merge( $children, get_term_children( $term, $taxonomy ) );
|
||||||
|
$children[] = $term;
|
||||||
|
}
|
||||||
|
$terms = $children;
|
||||||
|
$field = 'term_id';
|
||||||
|
}
|
||||||
|
|
||||||
$taxonomies = "'" . implode( "', '", $taxonomies ) . "'";
|
$taxonomies = "'" . implode( "', '", $taxonomies ) . "'";
|
||||||
|
|
||||||
switch ( $field ) {
|
switch ( $field ) {
|
||||||
case 'term_id':
|
case 'term_id':
|
||||||
$terms = array_map( 'intval', $terms );
|
$terms = array_map( 'intval', $terms );
|
||||||
|
|
||||||
if ( is_taxonomy_hierarchical( $taxonomy ) && $include_children ) {
|
|
||||||
$children = $terms;
|
|
||||||
foreach ( $terms as $term )
|
|
||||||
$children = array_merge( $children, get_term_children( $term, $taxonomy ) );
|
|
||||||
$terms = $children;
|
|
||||||
}
|
|
||||||
|
|
||||||
$terms = implode( ',', $terms );
|
$terms = implode( ',', $terms );
|
||||||
$sql = "
|
$sql = "
|
||||||
SELECT object_id
|
SELECT object_id
|
||||||
|
|
Loading…
Reference in New Issue