Summery Summery

Prepares a meta value for a response.

Syntax Syntax

WP_REST_Meta_Fields::prepare_value_for_response( mixed $value, WP_REST_Request $request, array $args )

Description Description

This is required because some native types cannot be stored correctly in the database, such as booleans. We need to cast back to the relevant type before passing back to JSON.

Parameters Parameters


(mixed) (Required) Meta value to prepare.


(WP_REST_Request) (Required) Current request object.


(array) (Required) Options for the field.

Return Return

(mixed) Prepared value.

Source Source

File: wp-includes/rest-api/fields/class-wp-rest-meta-fields.php

	protected function prepare_value_for_response( $value, $request, $args ) {
		if ( ! empty( $args['prepare_callback'] ) ) {
			$value = call_user_func( $args['prepare_callback'], $value, $request, $args );

		return $value;


Changelog Changelog

Version Description
4.7.0 Introduced.


Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.