Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $this->post_types = array ( 'post', 'location' );
- foreach( array( 'field_1', 'field_2' ) as $field ) {
- register_rest_field( $this->post_types,
- $field,
- array(
- 'get_callback' => array( $this, 'get_post_meta' ),
- 'update_callback' => array( $this, 'update_post_meta' ),
- 'schema' => null,
- )
- );
- }
- public function get_post_meta($object, $field_name, $request) {
- return get_post_meta( $object['id'], $field_name, true );
- }
- public function update_post_meta($value, $object, $field_name) {
- return update_post_meta( $object->ID, $field_name, $value );
- }
- response = await this.wordPress.cv_location().create({
- title: article.title,
- content: article.content,
- status: article.status,
- meta: {
- field_1: article.field_1,
- field_2: article.field_2,
- }
- });
Add Comment
Please, Sign In to add comment