register_rest_field for custom taxonomy fields that are assosiated with custom post type

Both callbacks in the register_rest_field_for_custom_taxonomy_location() function are misspelled.

change

'get_callback'    => 'location_get_term_meta',
'update_callback' => 'location_update_term_meta',

to

'get_callback'    => 'location_get_term_meta_field',
'update_callback' => 'location_update_term_meta_field',

Register Code

function register_rest_field_for_custom_taxonomy_location() {
    register_rest_field( 'location',
        'location_code',
        array(
            'get_callback'    => 'location_get_term_meta_field',
            'update_callback' => 'location_update_term_meta_field',
            'schema' => null,
        )
    );

Leave a Comment