Description
Get the primary term name.
Usage
$string = yoast_get_primary_term( $taxonomy, $post );
Parameters
- $taxonomy
- ( string ) optional default: category – Optional. The taxonomy to get the primary term for. Defaults to category.
- $post
- ( int|WP_Post|null ) optional – Optional. Post to get the primary term for.
Returns
string Name of the primary term.
Source
File name: wordpress-seo/inc/wpseo-functions.php
Lines:
1 to 10 of 10
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 ''; }