Parameters
$id
(integer or object) (optional) The ID of the post you'd like to fetch, or an object that specifies the post. By default the current post is fetched.
Default: null
$output
(string) (optional) How you'd like the result.
OBJECT - (default) returns a WP_Post object
ARRAY_A - Returns an associative array of field names to values
ARRAY_N - returns a numeric array of field values
Default: OBJECT
$filter
(string) (optional) Filter the post. See sanitize_post_field() for a full list of values.
raw - (default)
Default: raw
Return Values
Returns a WP_Post object, or null if the post doesnt exist or an error occurred.
Example
To get the title for a post with ID 7:
Parameters
$id
(integer or object) (optional) The ID of the post you'd like to fetch, or an object that specifies the post. By default the current post is fetched.
Default: null
$output
(string) (optional) How you'd like the result.
OBJECT - (default) returns a WP_Post object
ARRAY_A - Returns an associative array of field names to values
ARRAY_N - returns a numeric array of field values
Default: OBJECT
$filter
(string) (optional) Filter the post. See sanitize_post_field() for a full list of values.
raw - (default)
Default: raw
Return Values
Returns a WP_Post object, or null if the post doesnt exist or an error occurred.
Example
To get the title for a post with ID 7:
Parameters
$id
(integer or object) (optional) The ID of the post you'd like to fetch, or an object that specifies the post. By default the current post is fetched.
Default: null
$output
(string) (optional) How you'd like the result.
OBJECT - (default) returns a WP_Post object
ARRAY_A - Returns an associative array of field names to values
ARRAY_N - returns a numeric array of field values
Default: OBJECT
$filter
(string) (optional) Filter the post. See sanitize_post_field() for a full list of values.
raw - (default)
Default: raw
Return Values
Returns a WP_Post object, or null if the post doesnt exist or an error occurred.
Example
To get the title for a post with ID 7: