WordPress at a glance

get_post_custom_keys() WP 1.0

Retrieve meta field names for a post.

If there are no meta fields, then nothing (null) will be returned.

Is the basis for: the_meta()
Works based on: get_post_custom()

No Hooks.


Array/null. Array of the keys, if retrieved.


get_post_custom_keys( $post_id );
Post ID.
Default: ID of the global $post


Since 1.2.0 Introduced.

Code of get post custom keys: wp-includes/post.php WP 5.4.2

function get_post_custom_keys( $post_id = 0 ) {
	$custom = get_post_custom( $post_id );

	if ( ! is_array( $custom ) ) {

	$keys = array_keys( $custom );
	if ( $keys ) {
		return $keys;

Related Functions

From tag: Metadatas (any)

No comments
        Log In . Register