wp-includes/class-wp-comment.php:385Gets the children of a comment.
$argsarrayoptionalarray()$formatstringdefault: 'tree'
$statusstringdefault: 'all'
$hierarchicalstringdefault: 'threaded'
$orderbystring|array
$fieldsstringdefault: empty
$countbooldefault: false
$typestringdefault: empty
$numberintdefault: empty (no limit)
$post_idintdefault: 0
$orderstringdefault: 'DESC'
WP_Comment[]|int[]|int public function get_children( $args = array() ) { $defaults = array( 'format' => 'tree', 'status' => 'all', 'hierarchical' => 'threaded', 'orderby' => '', ); /** @var array{ format: 'tree'|'flat', status: string, hierarchical: 'threaded'|'flat'|false, orderby: string|string[]|false, fields?: 'ids'|'', count?: bool, type?: string, number?: int, post_id?: int, order?: 'ASC'|'DESC', ... } $_args */ $_args = wp_parse_args( $args, $defaults ); $_args['parent'] = $this->comment_ID; /* * A 'count' or 'ids' query returns an integer or a list of comment IDs rather than * WP_Comment objects. Neither may be written to the children cache, which holds * WP_Comment objects and is read back by add_child(), get_child(), and the 'flat' * format below. Return the result directly and leave the cache untouched. The two * branches must stay separate: each is narrowed independently, and `count` is only * safe to overwrite in the 'ids' branch. */ if ( ! empty( $_args['count'] ) ) { return get_comments( $_args ); } elseif ( isset( $_args['fields'] ) && 'ids' === $_args['fields'] ) { $_args['count'] = false; // For static analysis of the conditional return type. return get_comments( $_args ); } // Only WP_Comment objects are returned past this point. Stated positively for static analysis. $_args['count'] = false; $_args['fields'] = ''; if ( is_null( $this->children ) ) { if ( $this->populated_children ) { $this->children = array(); } else { $this->children = get_comments( $_args ); } } if ( 'flat' === $_args['format'] ) { $children = array(); foreach ( $this->children as $child ) { $child_args = $_args; $child_args['format'] = 'flat'; // get_children() resets this value automatically. unset( $child_args['parent'] ); $children = array_merge( $children, array( $child ), $child->get_children( $child_args ) ); } } else { $children = $this->children; } return $children; }Introduced in 4.4.0. One change between 6.7.7 and 7.1.0.
Signature, return type and hooks compared across 5 parsed releases.
WP_Comment[] to WP_Comment[]|int[]|int.verified against sourcesrc/wp-includes/class-wp-comment.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it.