registered_meta_key_exists

函数


registered_meta_key_exists ( $object_type, $meta_key, $object_subtype = '' )
参数
  • (string)
    $object_type
    Type of object metadata is for. Accepts ‘post’, ‘comment’, ‘term’, ‘user’, or any other object type with an associated meta table.
    Required:
  • (string)
    $meta_key
    Metadata key.
    Required:
  • (string)
    $object_subtype
    Optional. The subtype of the object type.
    Required:
    Default: (empty)
返回值
  • (bool) True if the meta key is registered to the object type and, if provided, the object subtype. False if not.
定义位置
  • wp-includes/meta.php
    , line 1587
引入
4.6.0
弃用

Checks if a meta key is registered.

function registered_meta_key_exists( $object_type, $meta_key, $object_subtype = '' ) {
	$meta_keys = get_registered_meta_keys( $object_type, $object_subtype );

	return isset( $meta_keys[ $meta_key ] );
}