get_post_custom_keys
Retrieve meta field names for a post.
Description
(array|void) get_post_custom_keys( (int) $post_id = 0 );
If there are no meta fields, then nothing (null) will be returned.
Returns (array|void)
Array of the keys, if retrieved.
Parameters (1)
- 0. $post_id — Optional. (int)
- Post ID. Default is ID of the global
$post
.
Usage
if ( !function_exists( 'get_post_custom_keys' ) ) { require_once ABSPATH . WPINC . '/post.php'; } // Optional. Post ID. Default is ID of the global $post. $post_id = -1; // NOTICE! Understand what this does before running. $result = get_post_custom_keys($post_id);
Defined (1)
The function is defined in the following location(s).
- /wp-includes/post.php
- function get_post_custom_keys( $post_id = 0 ) {
- $custom = get_post_custom( $post_id );
- if ( !is_array($custom) )
- return;
- if ( $keys = array_keys($custom) )
- return $keys;
- }