acf-to-rest-api
acf-to-rest-api copied to clipboard
Unable to hide field from REST API
I have this filter enabled in functions.php:
add_filter( 'acf/rest_api/field_settings/show_in_rest', '__return_true' );
The toggle Show in REST API? is visible in field settings but set to No by default. Despite that, all fields are still included in the API. Turning it on and back off does not remove them either.
This issue occurs on options page only, works as expected in other locations (posts, pages, etc.).
WordPress v5.5.1 Advanced Custom Fields PRO v5.9.1 ACF to REST API v3.3.1, Request Version v3
We are also experiencing the same issue, the options page ingores these settings.
Could be php caching? I wasn't seeing any change after editing my functions.php page. Took me a while to work out that you have to restart php after each edit if you have php opcache turned on. Doh!!
Same pb
If the options page has id 'options' the call to acf_get_field_groups in line 135 in class-acf-to-rest-act-api.php returns empty.
I made this fix in the same file line 131: if ($id == 'options') { $fields_tmp = get_field_objects( $id ); } elseif ....
I have only tested with one field group on the option page. It there are more, I dont know if it will work.
Yep, same -- I've applied a workaround similar to @johannesdb solution but unsure if it's a robust fix..