Forums

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.

  • This topic is empty.
Viewing 1 post (of 1 total)
  • Author
    Posts
  • #206602
    damienoneill2001
    Participant

    Hello,

    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.

    I have tried adding unset( $data['author']['first_name' ); but to no avail. The name still remains in the JSON code.

    Is there a way to remove just the 'first_name' of the author field?

    Thanks

    Damien

Viewing 1 post (of 1 total)
  • The forum ‘Back End’ is closed to new topics and replies.