Support

Account

Home Forums ACF PRO get_fields() but for Taxonomy Reply To: get_fields() but for Taxonomy

  • Unfortunately, that’s not my result. I’m getting false. Here’s my code that isn’t working. I’m trying to use the WP REST API to return custom fields on a custom Taxonomy called ‘region’ on a custom Post Type.

    function regions_get_custom_fields_cb($object, $field_name, $request){
        $thing = $object['slug'] . "_" . $object['id'];
        return get_fields($thing);
    }
    
    add_action('rest_api_init', function(){
        register_rest_field('region', 'custom_data', 
            array(
                'get_callback' => 'regions_get_custom_fields_cb', 
                'update_callback' => null, 
                'schema' => null
            )
        );
    });