post_custom()WP 1.5.0

Retrieves post custom meta data field.

Хуков нет.

Возвращает

Массив|Строку|false. Array of values, or single value if only one element exists. False if the key does not exist.

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

post_custom( $key );
$key(строка)
Meta data key name.
По умолчанию: ''

Список изменений

С версии 1.5.0 Введена.

Код post_custom() WP 6.5.2

function post_custom( $key = '' ) {
	$custom = get_post_custom();

	if ( ! isset( $custom[ $key ] ) ) {
		return false;
	} elseif ( 1 === count( $custom[ $key ] ) ) {
		return $custom[ $key ][0];
	} else {
		return $custom[ $key ];
	}
}