diff --git a/v3/lib/endpoints/class-acf-to-rest-api-controller.php b/v3/lib/endpoints/class-acf-to-rest-api-controller.php index ff1e5f4..8904ec7 100644 --- a/v3/lib/endpoints/class-acf-to-rest-api-controller.php +++ b/v3/lib/endpoints/class-acf-to-rest-api-controller.php @@ -49,7 +49,8 @@ public function register_routes() { } public function register_field() { - register_rest_field( $this->type, 'acf', array( + $type = ( 'post_tag' === $this->type ) ? 'tag' : $this->type; + register_rest_field( $type, 'acf', array( 'get_callback' => array( $this, 'register_field_callback' ), 'schema' => array( 'description' => __( 'Expose advanced custom fields.', 'acf-to-rest-api' ), @@ -123,7 +124,7 @@ public function update_item( $request ) { update_field( $field['key'], $value, $item['id'] ); } else { do_action( 'acf/update_value', $value, $item['id'], $field ); - } + } } } } @@ -136,13 +137,13 @@ public function update_item( $request ) { public function rest_insert( $object, $request, $creating ) { if ( $request instanceof WP_REST_Request ) { - $id = $this->acf->get_id( $object ); + $id = $this->acf->get_id( $object ); if ( ! $id ) { $id = $this->acf->get_id( $request ); } $request->set_param( 'id', $id ); } - + return $this->update_item( $request ); }