get_registered_meta_keys() WordPress Function

The get_registered_meta_keys() function retrieves all registered metadata keys for a given object type.

get_registered_meta_keys( string $object_type, string $object_subtype = '' ) #

Retrieves a list of registered meta keys for an object type.


Parameters

$object_type

(string)(Required)Type of object metadata is for. Accepts 'post', 'comment', 'term', 'user', or any other object type with an associated meta table.

$object_subtype

(string)(Optional) The subtype of the object type.

Default value: ''


Top ↑

Return

(string[]) List of registered meta keys.


Top ↑

Source

File: wp-includes/meta.php

function get_registered_meta_keys( $object_type, $object_subtype = '' ) {
	global $wp_meta_keys;

	if ( ! is_array( $wp_meta_keys ) || ! isset( $wp_meta_keys[ $object_type ] ) || ! isset( $wp_meta_keys[ $object_type ][ $object_subtype ] ) ) {
		return array();
	}

	return $wp_meta_keys[ $object_type ][ $object_subtype ];
}


Top ↑

Changelog

Changelog
VersionDescription
4.9.8The $object_subtype parameter was added.
4.6.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.