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

Top ↑

See also


Top ↑

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(),
			)
		);
	}


Top ↑

Changelog

Changelog
VersionDescription
5.6.0This method has been deprecated. Use register_rest_field() instead.
4.7.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.