函数原型
post_custom( string $key = ” ): array|string|false
函数描述
Retrieves post custom meta data field.
是否弃用
未弃用
函数参数
-
$key
string
Optional - Meta data key name.
Default:
''
函数返回值
array|string|false Array of values, or single value if only one element exists.
False if the key does not exist.
函数位置
File: wp-includes/post-template.php.
函数源码
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 ];
}
}
源码链接
变更日志
| Version | Description |
|---|---|
| 1.5.0 | Introduced. |

