I understand the difference between choosing Post Object and Post ID for the return format of an image as this can determine the markup and what values for the image are available to you.
However, could someone please help me understand why I might choose between ‘Post Object’ or ‘Post ID’ for a ‘Post Object’ field type. I seem to get the same results, and unlike on the Image docs page, for Post Object it only advises on display data for the post object return format, not for Post ID. I’m left wondering why I’d choose Post ID over Post Object in this context.
There are some functions that allow you to pass the post ID instead of the post object. So instead of using the post object with data that you don’t need, you can use the post ID instead. This will reduce the resource usage as ACF needs to query the database if it needs to return the post object.
I hope this makes sense 🙂
Yes it does, thanks James.
Hi, I’m sorry but it doesn’t make sense to me (yet).
I have both relationship and post_object fields, with ‘return_format’ set to ‘object’. Calling
get_field('field-name'); still returns the linked post(s) ID though.
What you’re saying is that in some cases you don’t need the whole post object, just the ID, in which case having the ID as return format would be sufficient, and faster. I don’t see how that is an answer, since both return formats return the ID, while neither of them return the post object?