函数原型
get_post_custom_values( string $key = ”, int $post_id ): array|null
函数描述
Retrieves values for a custom post field.
是否弃用
未弃用
函数参数
-
$key
string
Optional - Meta field key.
Default:
'' -
$post_id
int
Optional - Post ID. Default is the ID of the global
$post.
函数返回值
array|null Meta field values.
函数位置
File: wp-includes/post.php.
函数源码
function get_post_custom_values( $key = '', $post_id = 0 ) {
if ( ! $key ) {
return null;
}
$custom = get_post_custom( $post_id );
return isset( $custom[ $key ] ) ? $custom[ $key ] : null;
}
源码链接
变更日志
| Version | Description |
|---|---|
| 1.2.0 | Introduced. |

