get_post_custom()

You are here:

get_post_custom( int $post_id )

Retrieve post meta fields, based on post ID.

Description Description

The post meta fields are retrieved from the cache where possible, so the function is optimized to be called more than once.


Top ↑

Parameters Parameters

$post_id

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


Top ↑

Return Return

(array) Post meta for the given post.


Top ↑

More Information More Information

See also get_post_custom_keys() and get_post_custom_values()


Top ↑

Source Source

File: wp-includes/post.php

2217
2218
2219
2220
2221
2222
2223
2224
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 );
}


Top ↑

Changelog Changelog

Changelog
VersionDescription
1.2.0Introduced.
Was this article helpful?
Dislike 0
Views: 2

Cart

Log in

Create an Account
Back to Top