get_post_custom_values

The timeline below displays how wordpress function get_post_custom_values has changed across different WordPress versions. If a version is not listed, refer to the next available version below.

WordPress Version: 6.1

/**
 * Retrieves 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 the 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;
}

WordPress Version: 5.9

/**
 * 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 the 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;
}

WordPress Version: 4.3

/**
 * 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;
}

WordPress Version: 4.0

/**
 * 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 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;
}

WordPress Version: 3.7

/**
 * 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
 * @link http://codex.wordpress.org/Function_Reference/get_post_custom_values
 *
 * @param string $key Meta field key.
 * @param int $post_id Post ID
 * @return array 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;
}