Home › Forums › General Issues › Deeply nested post types › Reply To: Deeply nested post types
Not sure if you’re still looking for help on this. I’m actually a bit confused about the line
$posts = get_field( 'town' );
at the beginning of your code.
// single location template
get_header();
while (have_posts()) {
the_post();
$town = get_field( 'town' );
$county = get_field( 'county', $town->ID );
$state = get_field( 'state', $county->ID );
?>
<p>
Location: <?php the_title(); ?><br />
Town: <?php echo $town->post_title; ?><br />
County: <?php echo $county->post_title; ?><br />
State: <?php echo $state->post_title; ?><br />
</p>
<?php
}
get_footer();
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 Cookie Policy. If you continue to use this site, you consent to our use of cookies.