function my_rest_prepare_post( $data, $post, $request ) 
   $_data = $data->data;
   $_data[$field] = get_post_meta( $post->ID, 'my_custom_field_key', true );
   $data->data = $_data;
   return $data;

add_filter( ‘rest_prepare_post’, ‘my_rest_prepare_post’, 10, 3 );

Above is the code i am using to include meta value in API. But i want to include multiple meta i tried adding different meta key separating with , in my_custom_field_key but i displayed only first key’s value.

and second problem it only displayed Meta value how can i include key:value in json response.

Read more here: Get multiple post meta with WordPress REST API


If you know the solution of this issue, please leave us a reply in Comment section, to update the question.

Wordpress related questions and answers: