get_post_meta
Retrieve post meta field for a post.
Description
Parameters (3)
- 0. $post_id (int)
- The post id.
- 1. $key — Optional. (string) =>
''
- The meta key to retrieve. By default, returns data for all keys. Default empty.
- 2. $single — Optional. (bool) =>
false
- Whether to return a single value. Default false.
Usage
if ( !function_exists( 'get_post_meta' ) ) { require_once ABSPATH . WPINC . '/post.php'; } // The post id. $post_id = -1; // Optional. The meta key to retrieve. By default, returns // data for all keys. Default empty. $key = ''; // Optional. Whether to return a single value. Default false. $single = false; // NOTICE! Understand what this does before running. $result = get_post_meta($post_id, $key, $single);
Defined (1)
The function is defined in the following location(s).
- /wp-includes/post.php
- function get_post_meta( $post_id, $key = '', $single = false ) {
- return get_metadata('post', $post_id, $key, $single);
- }