Home Forums ACF PRO REST API wysiwyg returns stripped html Reply To: REST API wysiwyg returns stripped html

  • I don’t know the answer to this, I am just assuming.

    It appears that filters are not being applied to the content when you get it using rest api. ACF WYSIWYG fields depend on applying filters acf_the_content for formatting.

    Looking at the acf code I don’t see any reason why the content should not be formatted correctly, you might want to contact the developers.

    As a work-a-round you could add this by adding your own filter. There is an undocumented hook acf/rest/format_value_for_rest, this hook has all the standard variations similer to the acf/format_value hook

    return apply_filters( 'acf/rest/format_value_for_rest', $value_formatted, $post_id, $field, $value, $format );

    Looking into it more the way the field is formatted is based on an acf setting, "rest_api_format" and the default for this setting is “light”, and WYSIWYG fields are do not run through the standard format_value filters when set to light.

    So after all of what I said, the corrective action is to add a filter the changes this setting to “standard”. However, this will change how all values are filtered and may have undesired affects on other field types, so the value of other field types may not return what you are expecting. See this If you use a filter to change this setting then you’ll likely need to find a way to alter the setting only for specific field types, and I don’t see any way of doing that.