A few possibilities. One, is the Relational Post Object field set to output the Post ID or the Post Object? Just figured I’d ask in case it’s an easy fix, as it should be Post Object by the way you are using it 🙂
Second, retrieval by field name will only work if a value for that field has already been saved to th post/page in question, so that field-name<->field-key lookup data has been populated. Check out get_field_object() documentation, under the heading field_name vs field_key. It may not be readily apparent from the documentation, but for all functions that take a field name, you may (and really should) specify a field key. You may view the field keys of your fields by selecting Field Keys in the Screen Options of the Field Group add/edit screens.
Third, not specifying a post_id will only work if there is a current post setup. Is this code being executed within The Loop? Remember that even pages have a loop; it retrieves a single “post”. If not, you might want to specify the second parameter to get_field() ($post_id) or move your call to within The Loop.
Help your fellow forum-goers and moderation team; if a response solves your problem, please mark it as the solution. Thank you!
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!