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

Glossary Term

get_post_meta()

3 tags 1 category

get_post_meta() — Retrieves a post meta field for the given post ID.

Inputs: $post_id (int): Post ID. $key (string): Optional. The meta key to retrieve. By default, returns data for all keys. Default empty. $single (bool): Optional. Whether to return a single value. This parameter has no effect if $key is not specified. Default false.

Returns mixed: An array of values if $single is false. The value of the meta field if $single is true. False for an invalid $post_id (non-numeric, zero, or negative value). An empty array if a valid but non-existing post ID is passed and $single is false. An empty string if a valid but non-existing post ID is passed and $single is true. Note: Non-serialized values are returned as strings: false values are returned as empty strings (”) true values are returned as ‘1’ numbers (both integer and float) are returned as strings Arrays and objects retain their original type. These conversions apply to stored values. A default value registered with register_meta() is never stored, so it is returned with the type it was registered with, which may be an integer, float, or boolean.

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…