get_post


get_post ( $post = null, $output = OBJECT, $filter = 'raw' )

Parameters:
  • (int|WP_Post|null) $post Optional. Post ID or post object. Defaults to global $post.
  • (string) $output Optional. The required return type. One of OBJECT, ARRAY_A, or ARRAY_N, which correspond to a WP_Post object, an associative array, or a numeric array, respectively. Default OBJECT.
  • (string) $filter Optional. Type of filter to apply. Accepts 'raw', 'edit', 'db', or 'display'. Default 'raw'.
Returns:
  • (WP_Post|array|null) Type corresponding to $output on success or null on failure. When $output is OBJECT, a `WP_Post` instance is returned.
Defined at:

Description

Retrieves post data given a post ID or post object.

See sanitize_post() for optional $filter values. Also, the parameter $post, must be given as a variable, since it is passed by reference.

Related Functions

get_posts, edit_post, next_post, get_postdata, next_posts

Top Google Results

User discussions

wpseek mobile