acf_get_post_type_label()ACF 5.4.0

acf_get_post_type_label

This function will return a pretty label for a specific post_type

No Hooks.

Returns

(String).

Usage

acf_get_post_type_label( $post_type );
$post_type(required)
.

Changelog

Since 5.4.0 Introduced.

acf_get_post_type_label() code ACF 6.8.8

function acf_get_post_type_label( $post_type ) {

	// vars
	$label = $post_type;

	// check that object exists
	// - case exists when importing field group from another install and post type does not exist
	if ( post_type_exists( $post_type ) ) {
		$obj   = get_post_type_object( $post_type );
		$label = $obj->labels->singular_name;
	}

	// return
	return $label;
}