Retrieves data from a post field based on Post ID.
Description
Examples of the post field will be, 'post_type', 'post_status', 'post_content', etc and based off of the post object property or key names. The context values are based off of the taxonomy filter functions and supported values are found within those functions.
Parameters
$fieldstring
Post field name.
$postint|WP_Postoptional
Post ID or post object. Defaults to global $post.Default: null
$contextstringoptional
How to filter the field. Accepts 'raw', 'edit', 'db', or 'display'. Default 'display'.Default: 'display'
Return
int|string|int[]
The value of the post field on success, empty string on failure.
Uses · 2
get_post()Retrieves post data given a post ID or post object.
Signature, return type and hooks compared across 5 parsed releases.
6.9.7
Return type changed from string to int|string|int[].verified against source
4.5.0
The $post parameter was made optional.from the docblock
2.3.0
Introduced.from the docblock
About this page
Parsed data
Generated from the wordpress-develop 7.0.4 tag, from src/wp-includes/post.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it.
Corrections
Something wrong on this page? Report it and it gets fixed in the next regeneration.