How to post an unserialized array via wordpress rest API as meta data


I am new to wordpress and am currently using WordPress Rest API to help automatically create custom posts using existing data. 1 of the fields needed is an array of image IDs so that images can be displayed. If a post is manually created on wordpress with the images, I know that the meta data would need to be in this format


However, after posting through WordPress Rest API, the meta data automatically becomes serialized as such and no image is displayed.


Is there a way to prevent the auto serialization of my data?


function add_fave_property_images() {
            'get_callback' => 'get_post_meta_for_api',
            'update_callback' => 'rest_update_property_meta',
            'schema' => array(
                                'type'  => 'array',
                                'items' => array(
                                    'type'   => 'string',

function get_post_meta_for_api( $object ) {
    //return the post meta
    return get_post_meta( $post->ID, $field_name);

function rest_update_property_meta($value, $post, $field_name) {

  // Update the field
  return update_post_meta($post->ID, $field_name, $value);

I have also tried maybe_unserialize() to no avail. I would appreciate any help thank you!

user209330 1 year 2021-07-23T05:00:45-05:00 0 Answers 0 views 0

Leave an answer