times / acf-to-wp-api

Puts all ACF fields from posts, pages, custom post types, attachments and taxonomy terms, into the WP-API output under the 'acf' key

Home Page:http://wordpress.org/plugins/acf-to-wp-api/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Nested ACF fields

cpeddecord opened this issue · comments

Hello! Was wondering if it was possible to get nested ACF fields within a repeater or otherwise. And if possible, how many levels of nesting could one go before it became ludicrous?

Hey @cpeddecord,

I'm not sure I fully understand what you're expecting. Could you post your ACF configuration and the expected API output?

Hey @chrishutchinson!

the post I'm looking at spits out its json similar to this (other keys removed for brevity):

{
  "ID": 123,
  "acf": {
    "flexible_content": [
      "acf_fc_layout": "relationship_object",
      "single_post": {
        "ID": 456,
        "post_content": "Such Content"
      }
    ]
  }
}

In an ideal world, the nested post (ID: 456) in the flexible content would also return its own acf field as well.

{
  "ID": 123,
  "acf": {
    "flexible_content": [
      "acf_fc_layout": "relationship_object",
      "single_post": {
        "ID": 456,
        "post_content": "Such Content",
        "acf": {
          "acf_text": "Hello World"
        }
      }
    ]
  }
}

Hey @cpeddecord,

This has cropped up before in #16 and I made the call not to include those fields for various reasons, which I've listed in that issue log.

Hopefully that doesn't prevent you from using the plugin, particularly as my suggested approach is to make a secondary request to the WP-API to get that data.