Home Forums Add-ons Flexible Content Field Displaying Relationship Content Within Flexible Content?


Displaying Relationship Content Within Flexible Content?

  • Is it possible to show a related field within flexible content, i’ve tried the below with now luck, the ‘read more’ link doesn’t display?

    <!--Field Name-->
    <?php if( have_rows('home_slide') ): ?>
    										 			<!--Field Name-->
    <?php while( have_rows('home_slide') ): the_row(); ?>
    										 							<!--Layout Name-->										<?php if( get_row_layout() == 'home_slide_content' ):?>
    																				<?php $posts = the_sub_field('home_slide_link’); if( $posts ): ?>
    											    <?php foreach( $posts as $post): // variable must be called $post (IMPORTANT) ?>
    											        <?php setup_postdata($post); ?>
    											            <a class="read" href="<?php the_permalink(); ?>">Read More</a>
    											    <?php endforeach; ?>
    											    <?php wp_reset_postdata(); // IMPORTANT - reset the $post object so the rest of the page works correctly ?>
    											<?php endif; ?>
    										<?php endif; ?>
    <?php endwhile; ?>
    <?php endif; ?>
  • Apologies, figured out that the_sub_field needed to be get_sub_field

Viewing 2 posts - 1 through 2 (of 2 total)

The topic ‘Displaying Relationship Content Within Flexible Content?’ is closed to new replies.