Yoast\WP\SEO\Generators\Schema
Article::add_terms()
Adds a term or multiple terms, comma separated, to a field.
Метод класса: Article{}
Хуков нет.
Возвращает
Разное
. Article data.
Использование
// protected - в коде основоного (родительского) или дочернего класса $result = $this->add_terms( $data, $key, $taxonomy );
- $data(массив) (обязательный)
- Article data.
- $key(строка) (обязательный)
- The key in data to save the terms in.
- $taxonomy(строка) (обязательный)
- The taxonomy to retrieve the terms from.
Код Article::add_terms() Article::add terms Yoast 20.3
protected function add_terms( $data, $key, $taxonomy ) { $terms = \get_the_terms( $this->context->id, $taxonomy ); if ( ! \is_array( $terms ) ) { return $data; } $callback = static function( $term ) { // We are using the WordPress internal translation. return $term->name !== \__( 'Uncategorized', 'default' ); }; $terms = \array_filter( $terms, $callback ); if ( empty( $terms ) ) { return $data; } $data[ $key ] = \wp_list_pluck( $terms, 'name' ); return $data; }