get_post_custom_values()

最后更新于:2021-11-26 22:29:07

get_post_custom_values( string$key=”, int$post_id)

Retrieve values for a custom post field.

参数

$key

(string) (Optional) Meta field key.

Default value: ”

$post_id

(int) (Optional) Post ID. Default is ID of the global $post.

响应

(array|null) Meta field values.

源文件

文件: gc-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;
}