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

You appear to be a bot. Output may be restricted

Description

Retrieves a post meta field for the given post ID.

Usage

$mixed = get_post_meta( $post_id, $key, $single );

Parameters

$post_id
( int ) required – Post ID.
$key
( string ) optional – Optional. The meta key to retrieve. By default, returns data for all keys. Default empty.
$single
( bool ) optional – 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 string if a valid but non-existing post ID is passed.

Source

File name: wordpress/wp-includes/post.php
Lines:

1 to 3 of 3
function get_post_meta( $post_id, $key = '', $single = false ) {
  return get_metadata( 'post', $post_id, $key, $single );
}
 

 View on GitHub View on Trac