registered_meta_key_exists

Checks if a meta key is registered.

Description

registered_meta_key_exists( (string) $object_type, (string) $meta_key ); 

Parameters (2)

0. $object_type (string)
The type of object.
1. $meta_key (string)
The meta key.

Usage

  1. if ( !function_exists( 'registered_meta_key_exists' ) ) { 
  2. require_once ABSPATH . WPINC . '/meta.php'; 
  3.  
  4. // The type of object. 
  5. $object_type = ''; 
  6.  
  7. // The meta key. 
  8. $meta_key = ''; 
  9.  
  10. // NOTICE! Understand what this does before running. 
  11. $result = registered_meta_key_exists($object_type, $meta_key); 
  12.  

Defined (1)

The function is defined in the following location(s).

/wp-includes/meta.php  
  1. function registered_meta_key_exists( $object_type, $meta_key ) { 
  2. global $wp_meta_keys; 
  3.  
  4. if ( ! is_array( $wp_meta_keys ) ) { 
  5. return false; 
  6.  
  7. if ( ! isset( $wp_meta_keys[ $object_type ] ) ) { 
  8. return false; 
  9.  
  10. if ( isset( $wp_meta_keys[ $object_type ][ $meta_key ] ) ) { 
  11. return true; 
  12.  
  13. return false;