The What
Syntax
WP_Post|array|null get_post ( int|WP_Post|null $post_object_or_id = null, string $return_data_type = OBJECT, string $field_filter = 'raw' );
Description
This function fetches the post data from the database (or cache) for the given post ID or post object.
Parameters
post_object_or_id
- optional The post ID or object which is used to fetch the data related to the one you want.
return_data_type
- optional Data type you want back from
get_post
. Choices are:OBJECT
,ARRAY_A
, orARRAY_N
. It defaults toOBJECT
. field_filter
- optional Sanitizing filter you want to run on all of the fields in the post data. You will need to use sanitize_post and configure up which filters to apply. It defaults to
raw
. Choices are:raw
,edit
,db
, ordisplay
.
Return Values
Returns the post data in the data type you requested. If something went wrong, such as the post does not exist, null
is returned.
You get WET when you swim. Stay DRY when you code.
More coming soon…keep checking back.