yoast_get_primary_term()Yoast 1.0

Get the primary term name.

Хуков нет.

Возвращает

Строку. Name of the primary term.

Использование

yoast_get_primary_term( $taxonomy, $post );
$taxonomy(строка)
The taxonomy to get the primary term for.
По умолчанию: category
$post(int|WP_Post|null)
Post to get the primary term for.
По умолчанию: null

Код yoast_get_primary_term() Yoast 19.7.2

function yoast_get_primary_term( $taxonomy = 'category', $post = null ) {
	$primary_term_id = yoast_get_primary_term_id( $taxonomy, $post );

	$term = get_term( $primary_term_id );
	if ( ! is_wp_error( $term ) && ! empty( $term ) ) {
		return $term->name;
	}

	return '';
}