Support

Account

Home Forums General Issues Understanding Return Format: Post Object vs Post ID

Solving

Understanding Return Format: Post Object vs Post ID

  • Following this old topic by @cargoodrich:

    Although the topic was marked as solved, @janklass stated at the end that even when using the Post Object return format, he was still getting just an ID instead of a Post Object.

    The same happens to me. When I use Post Object as return format, the behaviour seems erratic, and get_field('field-name'); returns an ID instead of an object.

    For this reason I prefer to choose Post ID as return format, as I know for sure what it returns. I would love to use Post Object, but I don’t understand why is it returning an ID instead of an object.

  • Are you using bi-directional relationships? (there’s a checkbox on the relationship field)

  • @floatingpoint Just the Post Object field.

    With further testing, it seems that it is the Taxonomy field that returns an ID instead of a Term Object even when the return format is Term Object.

    Or maybe this is happening only when I access properties directly instead of using get_field(). I would expect the return type to save the data in that format, but maybe it is storing only IDs in any case, and only using ACF functions does it return the specified format.

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.