The forums ran from 2008-2020 and are now closed and viewable here as an archive.
Home › Forums › Back End › Removing nested JSON fields from WP-API.
After reading the Using the WP-API to Fetch Posts article, https://css-tricks.com/using-the-wp-api-to-fetch-posts/, I found the unset feature very useful to switch off fields that were not needed, however, I was wondering if someone knew how to remove nested fields.
For example, adding unset( $data['author'] ); will remove the full set of Author information, such as the First Name, Last Name, Nickname, Avatar, etc.
unset( $data['author'] );
I have tried adding unset( $data['author']['first_name' ); but to no avail. The name still remains in the JSON code.
unset( $data['author']['first_name' );
Is there a way to remove just the 'first_name' of the author field?