post_custom( string $key = '' ): array|string|false
Retrieves post custom meta data field.
Parameters
-
$key
string Optional -
Meta data key name.
Default:
''
Return
array|string|false Array of values, or single value if only one element exists.
False if the key does not exist.
Source
File: wp-includes/post-template.php
.
View all references
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 ];
}
}
Changelog
Version | Description |
---|---|
1.5.0 | Introduced. |