acf_get_term_title()ACF 5.0.0

acf_get_term_title

Returns the title for this term object.

No Hooks.

Returns

String.

Usage

acf_get_term_title( $term );
$term(object) (required)
The WP_Term object.

Changelog

Since 5.0.0 Introduced.

acf_get_term_title() code ACF 6.8.8

function acf_get_term_title( $term ) {
	$title = $term->name;

	// Allow for empty name.
	if ( $title === '' ) {
		$title = __( '(no title)', 'acf' );
	}

	// Prepend ancestors indentation.
	if ( is_taxonomy_hierarchical( $term->taxonomy ) ) {
		$ancestors = get_ancestors( $term->term_id, $term->taxonomy );
		$title     = str_repeat( '- ', count( $ancestors ) ) . $title;
	}

	return $title;
}