WordPress at Your Fingertips
function is not described

WP_Term_Query::populate_terms() protected WP 4.9.8

Creates an array of term objects from an array of term IDs.

Also discards invalid term objects.

{} It's a method of the class: WP_Term_Query{}

No Hooks.

Return

Array.

Usage

// protected - for code of main (parent) or child class
$result = $this->populate_terms( $term_ids );
$term_ids(array) (required)
Term IDs.

Changelog

Since 4.9.8 Introduced.

Code of WP_Term_Query::populate_terms() WP 5.8.2

protected function populate_terms( $term_ids ) {
	$terms = array();

	if ( ! is_array( $term_ids ) ) {
		return $terms;
	}

	foreach ( $term_ids as $key => $term_id ) {
		$term = get_term( $term_id );
		if ( $term instanceof WP_Term ) {
			$terms[ $key ] = $term;
		}
	}

	return $terms;
}