pathardepavan (@pathardepavan)

Forum Replies Created

Viewing 2 replies - 1 through 2 (of 2 total)

  • pathardepavan
    Participant

    @pathardepavan

    Please find the code below.. I am sure it must be a very small error

    add_action( 'rest_api_init', function() {
     register_api_field( 'topic',
        'post_parent',
        array(
           'get_callback'    => 'slug_get_post_meta_cb',
           //'update_callback' => 'slug_update_post_meta_cb',
           'update_callback' => 'slug_update_spaceship2',
           'schema'          => null,
        )
     );
    
    });
    
     
    function slug_update_spaceship2( $value, $object, $field_name ) {
       
       return update_post_meta( $object->ID, $field_name, $value);
    
    }
    function slug_get_post_meta_cb( $object, $field_name, $request ) {
        return get_post_meta( $object['id'], $field_name );
    }
    In reply to: Designing Forum

    pathardepavan
    Participant

    @pathardepavan

    @robkk I am a php developer myself but can you guide me on how can i achieve this ?

Viewing 2 replies - 1 through 2 (of 2 total)