Warning: This method has been deprecated. Use register_rest_field() instead.
WP_REST_Meta_Fields::register_field() WordPress Method
The register_field() method is used to register a new meta field for use with the WordPress REST API. This method takes two arguments: the field name and an array of options. The options array can contain the following keys: 'callback' => The function that will be called to sanitize the field value. 'type' => The field type. Valid values are 'string', 'boolean', 'integer', 'number', and 'array'. 'single' => Whether the field will be a single value or an array of values. 'description' => A description of the field. 'show_in_rest' => Whether the field will be exposed in the WordPress REST API. The register_field() method should be called from the 'rest_api_init' action hook.
WP_REST_Meta_Fields::register_field() #
Registers the meta field.
Description
See also
Source
File: wp-includes/rest-api/fields/class-wp-rest-meta-fields.php
public function register_field() {
_deprecated_function( __METHOD__, '5.6.0' );
register_rest_field(
$this->get_rest_field_type(),
'meta',
array(
'get_callback' => array( $this, 'get_value' ),
'update_callback' => array( $this, 'update_value' ),
'schema' => $this->get_field_schema(),
)
);
}
Expand full source codeCollapse full source codeView on TracView on GitHub
Changelog
| Version | Description |
|---|---|
| 5.6.0 | This method has been deprecated. Use register_rest_field() instead. |
| 4.7.0 | Introduced. |