Skip to content

Allow the case of post object to be interrupted as an array value#12

Open
mboswell-kp wants to merge 1 commit into
es-signed-requestfrom
acf-post-object
Open

Allow the case of post object to be interrupted as an array value#12
mboswell-kp wants to merge 1 commit into
es-signed-requestfrom
acf-post-object

Conversation

@mboswell-kp
Copy link
Copy Markdown

A field of type post_object with the attribute multiple set to true was yielding incorrect data results.

Example JSON for fields.json

{
              "label": "Foobar",
              "name": "foobar",
              "type": "post_object",
              "required": 0,
              "conditional_logic": 0,
              "wrapper": {
                "width": "",
                "class": "",
                "id": ""
              },
              "post_type": [
                "foos"
              ],
              "taxonomy": "",
              "allow_null": 0,
              "multiple": 1,
              "return_format": "object",
              "ui": 1
}

With multiple posts saved in the acf field the value sent to parse_acf_field would have the following shape:

[array]
 - WP_Post
 - WP_Post
 - WP_Post
 - ...

A call to get_post with this array value always returns the first post as WordPress's native code casts it to an integer.

This fix should allow the post object to be able to handle an attribute of multiple thus serializing multiple post objects.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant