get_post_custom_values()
get_post_custom_values( string $key = ”, int $post_id )
检索自定义post字段的值。
Retrieve values for a custom post field.
说明(Description)
参数不能被认为是可选的。将检索所有post元字段,只返回元字段键值。
参数(Parameters)
参数 | 类型 | 必填 | 说明 |
---|---|---|---|
$key | (string) | 可选 | 元字段键。 |
$post_id | (int) | 可选 | Post ID。默认值是全局$Post的ID。 |
返回(Return)
(array|null)元字段值。
源码(Source)
/** * Retrieve values for a custom post field. * * The parameters must not be considered optional. All of the post meta fields * will be retrieved and only the meta field key values returned. * * @since 1.2.0 * * @param string $key Optional. Meta field key. Default empty. * @param int $post_id Optional. Post ID. Default is ID of the global $post. * @return array|null Meta field values. */ 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; }
更新版本 | 源码位置 | 使用 | 被使用 |
---|---|---|---|
1.2.0 | wp-includes/post.php:2253 | 1 function | 1 function |
笔记(Notes)
默认用法示例。
get_post_custom_values() 为WP2原创文章,链接:https://www.wp2.cn/functions/get_post_custom_values/