get_post_custom

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

WordPress Version: 6.1

/**
 * Retrieves post meta fields, based on post ID.
 *
 * The post meta fields are retrieved from the cache where possible,
 * so the function is optimized to be called more than once.
 *
 * @since 1.2.0
 *
 * @param int $post_id Optional. Post ID. Default is the ID of the global `$post`.
 * @return mixed An array of values.
 *               False for an invalid `$post_id` (non-numeric, zero, or negative value).
 *               An empty string if a valid but non-existing post ID is passed.
 */
function get_post_custom($post_id = 0)
{
    $post_id = absint($post_id);
    if (!$post_id) {
        $post_id = get_the_ID();
    }
    return get_post_meta($post_id);
}

WordPress Version: 5.9

/**
 * Retrieve post meta fields, based on post ID.
 *
 * The post meta fields are retrieved from the cache where possible,
 * so the function is optimized to be called more than once.
 *
 * @since 1.2.0
 *
 * @param int $post_id Optional. Post ID. Default is the ID of the global `$post`.
 * @return array Post meta for the given post.
 */
function get_post_custom($post_id = 0)
{
    $post_id = absint($post_id);
    if (!$post_id) {
        $post_id = get_the_ID();
    }
    return get_post_meta($post_id);
}

WordPress Version: 4.0

/**
 * Retrieve post meta fields, based on post ID.
 *
 * The post meta fields are retrieved from the cache where possible,
 * so the function is optimized to be called more than once.
 *
 * @since 1.2.0
 *
 * @param int $post_id Optional. Post ID. Default is ID of the global $post.
 * @return array Post meta for the given post.
 */
function get_post_custom($post_id = 0)
{
    $post_id = absint($post_id);
    if (!$post_id) {
        $post_id = get_the_ID();
    }
    return get_post_meta($post_id);
}

WordPress Version: 3.7

/**
 * Retrieve post meta fields, based on post ID.
 *
 * The post meta fields are retrieved from the cache where possible,
 * so the function is optimized to be called more than once.
 *
 * @since 1.2.0
 * @link http://codex.wordpress.org/Function_Reference/get_post_custom
 *
 * @param int $post_id Post ID.
 * @return array
 */
function get_post_custom($post_id = 0)
{
    $post_id = absint($post_id);
    if (!$post_id) {
        $post_id = get_the_ID();
    }
    return get_post_meta($post_id);
}