Display custom field from parent post
-
I need to display a custom field from the parent connected post. It’s easier to describe through the code:
$connected = new WP_Query( array( 'connected_type' => 'programs_to_facilities', 'connected_items' => get_queried_object(), 'nopaging' => true, ) ); // Display connected facility if ( $connected->have_posts() ) : ?> <div class="facility"> <?php while ( $connected->have_posts() ) : $connected->the_post(); ?> <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a> <address> <?php the_field('facility_address'); ?>, <?php the_field('facility_city'); ?> OH <?php the_field('facility_zip'); ?> ? <?php the_field('program_main_phone'); ?> </address> <?php endwhile; ?> </div> <?php // Prevent weirdness wp_reset_postdata(); endif;
Where I have program_main_phone, that is from the parent connected post. In this case the Parent post is of post type ‘program’ and this code displays the connected ‘facility’ but I do need to display one field from the parent post. Is this possible?
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Display custom field from parent post’ is closed to new replies.