WP_Term_Query::populate_terms()
Creates an array of term objects from an array of term IDs.
Also discards invalid term objects.
Метод класса: WP_Term_Query{}
Хуков нет.
Возвращает
WP_Term[]
. Array of WP_Term objects.
Использование
// protected - в коде основоного (родительского) или дочернего класса $result = $this->populate_terms( $terms );
- $terms(Object[]|int[]) (обязательный)
- List of objects or term ids.
Список изменений
С версии 4.9.8 | Введена. |
Код WP_Term_Query::populate_terms() WP Term Query::populate terms WP 6.4.3
protected function populate_terms( $terms ) { $term_objects = array(); if ( ! is_array( $terms ) ) { return $term_objects; } foreach ( $terms as $key => $term_data ) { if ( is_object( $term_data ) && property_exists( $term_data, 'term_id' ) ) { $term = get_term( $term_data->term_id ); if ( property_exists( $term_data, 'object_id' ) ) { $term->object_id = (int) $term_data->object_id; } if ( property_exists( $term_data, 'count' ) ) { $term->count = (int) $term_data->count; } } else { $term = get_term( $term_data ); } if ( $term instanceof WP_Term ) { $term_objects[ $key ] = $term; } } return $term_objects; }