WP_Term_Query::populate_terms( array $term_ids )

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


Description Description

Also discards invalid term objects.


Top ↑

Parameters Parameters

$term_ids

(array) (Required) Term IDs.


Top ↑

Return Return

(array)


Top ↑

Source Source

File: wp-includes/class-wp-term-query.php

	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;
	}


Top ↑

Changelog Changelog

Changelog
Version Description
4.9.8 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.