Support

Account

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();