Opens in a new tab
A picture of Jeff Brigman
I CODE TODAY FOR
A BETTER TOMORROW

Glossary Term

get_post()

3 tags 1 category

get_post() — 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.

Inputs: $post (int|object|null): Optional. Post ID or post object. null, false, 0 and other PHP falsey values return the current global post inside the loop. A numerically valid post ID that points to a non-existent post returns null. Defaults to global $post. $output (string): 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. $filter (string): 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.

Term Connections

Explore related terms connected by shared tags, shared categories, and relationship phrases. This map loads only when it comes into view.

Loading term connections…