post_custom()
Retrieves post custom meta data field.
No Hooks.
Returns
Array|String|false. Array of values, or single value if only one element exists. False if the key does not exist.
Usage
post_custom( $key );
- $key(string)
- Meta data key name.
Default:''
Changelog
| Since 1.5.0 | Introduced. |
post_custom() post custom code WP 7.0
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 ];
}
}