yoast_get_primary_term_id()Yoast 1.0

Get the primary term ID.

Хуков нет.

Возвращает

true|false|int.

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

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

Код yoast_get_primary_term_id() Yoast 22.4

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

	$primary_term = new WPSEO_Primary_Term( $taxonomy, $post->ID );
	return $primary_term->get_primary_term();
}