Retrieve all children of the post parent ID.

Normally, without any enhancements, the children would apply to pages. In the context of the inner workings of WordPress, pages, posts, and attachments share the same table, so therefore the functionality could apply to any one of them. It is then noted that while this function does not work on posts, it does not mean that it won’t work on posts. It is recommended that you know what context you wish to retrieve the children of.

Attachments may also be made the child of a post, so if that is an accurate statement (which needs to be verified), it would then be possible to get all of the attachments for a post. Attachments have since changed since version 2.5, so this is most likely unaccurate, but serves generally as an example of what is possible.

The arguments listed as defaults are for this function and also of the

Signature

get_children( $args = '', $output = 'OBJECT' )
args
 (mixed) Optional. User defined arguments for replacing the defaults. Default empty.
Default: ''
output
 (string) Optional. Constant for return type. Accepts OBJECT, ARRAY_A, ARRAY_N. Default OBJECt.
Default: 'OBJECT'

Return

(array) Array of children, where the type of each element is determined by $output parameter. Empty array on failure.

Source

function get_children( $args = '', $output = OBJECT ) {
	$kids = array();
	if ( empty( $args ) ) {
		if ( isset( $GLOBALS['post'] ) ) {
			$args = array('post_parent' => (int) $GLOBALS['post']->post_parent );
		} else {
			return $kids;
		}
	} elseif ( is_object( $args ) ) {
		$args = array('post_parent' => (int) $args->post_parent );
	} elseif ( is_numeric( $args ) ) {
		$args = array('post_parent' => (int) $args);
	}

	$defaults = array(
		'numberposts' => -1, 'post_type' => 'any',
		'post_status' => 'any', 'post_parent' => 0,
	);

	$r = wp_parse_args( $args, $defaults );
28 more lines...
WP Trac GitHub

Link here