Home › Forums › General Issues › Deeply nested post types › Reply To: Deeply nested post types
a relationship field returns an array of objects, that’s why there is an error. Since a location can only be in one town, one town per city, etc, you might be better off using a Post Object field, which will only allow one.
With a post object field the code I posted will work.
For a relationship field you’d need to loop through each array, or if you have these limited to only allow one item you could use something like
Location: <?php the_title(); ?><br />
Town: <?php echo $town[0]->post_title; ?><br />
County: <?php echo $county[0]->post_title; ?><br />
State: <?php echo $state[0]->post_title; ?><br />
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!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.