_get_term_children example

$term_list[] = $term->term_id;
            } else {
                $term_list[] = $term;
            }

            if ( ! isset( $has_children[ $term->term_id ] ) ) {
                continue;
            }

            $ancestors[ $term->term_id ] = 1;

            $children = _get_term_children( $term->term_id, $terms$taxonomy$ancestors );
            if ( $children ) {
                $term_list = array_merge( $term_list$children );
            }
        }
    }

    return $term_list;
}

/** * Adds count of children to parent count. * * Recalculates term counts by including items from child terms. Assumes all * relevant children are already in the $terms argument. * * @access private * @since 2.3.0 * * @global wpdb $wpdb WordPress database abstraction object. * * @param object[]|WP_Term[] $terms List of term objects (passed by reference). * @param string $taxonomy Term context. */
return array();
        }

        $term_ids = wp_list_pluck( $terms, 'term_id' );
        _prime_term_caches( $term_ids, false );
        $term_objects = $this->populate_terms( $terms );

        if ( $child_of ) {
            foreach ( $taxonomies as $_tax ) {
                $children = _get_term_hierarchy( $_tax );
                if ( ! empty( $children ) ) {
                    $term_objects = _get_term_children( $child_of$term_objects$_tax );
                }
            }
        }

        // Update term counts to include children.         if ( $args['pad_counts'] && 'all' === $_fields ) {
            foreach ( $taxonomies as $_tax ) {
                _pad_term_counts( $term_objects$_tax );
            }
        }

        
Home | Imprint | This part of the site doesn't use cookies.