WPSEO_Replace_Vars::retrieve_primary_category()
Retrieve primary category for use as replacement string.
Метод класса: WPSEO_Replace_Vars{}
Хуков нет.
Возвращает
true|false|int|null
.
Использование
// private - только в коде основоного (родительского) класса $result = $this->retrieve_primary_category();
Код WPSEO_Replace_Vars::retrieve_primary_category() WPSEO Replace Vars::retrieve primary category Yoast 24.9
private function retrieve_primary_category() { $primary_category = null; if ( ! empty( $this->args->ID ) ) { $wpseo_primary_category = new WPSEO_Primary_Term( 'category', $this->args->ID ); $term_id = $wpseo_primary_category->get_primary_term(); $term = get_term( $term_id ); if ( ! is_wp_error( $term ) && ! empty( $term ) ) { $primary_category = $term->name; } } return $primary_category; }