-
-
Notifications
You must be signed in to change notification settings - Fork 111
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rename from 'acf' in JSON #41
Comments
Hi @justinackermann, The wildcard {type} can be: post, page, user, term, comment, attachment, options or custom_post_type ( book )... Thanks add_filter( 'acf/rest_api/{type}/get_fields', function( $data ) {
if ( method_exists( $data, 'get_data' ) ) {
$data = $data->get_data();
} else {
$data = (array) $data;
}
if ( isset( $data['acf'] ) ) {
$data['key'] = $data['acf'];
unset( $data['acf'] );
}
return $data;
} ); |
I think you misunderstood me or I am misunderstanding you. Currently my json is for example: I would like it to be something like: For mapping purposes on external sources I do not want to use the 'acf' naming. |
add_filter( 'acf/rest_api/{type}/get_fields', function( $data ) {
if ( method_exists( $data, 'get_data' ) ) {
$data = $data->get_data();
} else {
$data = (array) $data;
}
if ( isset( $data['acf'] ) ) {
$data['custom_naming_scheme'] = $data['acf'];
unset( $data['acf'] );
}
return $data;
} ); |
Thanks! This is just what I was looking for! |
Is there a way to edit how the acf fields show in the JSON listing? For example I do not want my custom field to show under the field 'acf' but something custom. With the old plugin I was able to find how to change this but with V2 I am unable to find where this is set.
The text was updated successfully, but these errors were encountered: