Support

Account

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 />