Skip to content

add cats  #2

@Amenocy

Description

@Amenocy

hi

register_rest_field('category', 'custom_fields', array(
                'get_callback' => array( $this, 'cat_get_custom_data' ),
                'update_callback' => array( $this, 'cat_update_custom_data' ),
                'schema' => array(
                    'description' => 'My custom field',
                    'type' => 'string',
                    'context' => array('view', 'edit')
                )
            )
        );
function cat_update_custom_data($value, $post, $field_name) {
        } 

function cat_get_custom_data($object, $field_name, $request) {
        if ( function_exists('get_fields') ) {
        return get_fields($object['taxonomy'] . '_' . $object['id']);
        }
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions