<?php while(has_sub_field("related_blogs")): ?>
<?php if(get_row_layout() == "title"):?>
<h4><?php the_sub_field('title');?></h4>
<?php elseif(get_row_layout() == "relationship"):?>
<?php
$posts = get_sub_field('relationship');
if( $posts ): ?>
<ul class="members-list">
<?php foreach( $posts as $post): // variable must be called $post (IMPORTANT) ?>
<?php setup_postdata($post); ?>
<li>
<a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
</li>
<?php endforeach; ?>
</ul>
<?php wp_reset_postdata(); // IMPORTANT - reset the $post object so the rest of the page works correctly ?>
<?php endif; ?>
<?php endif; ?>
<?php endwhile; ?>
More ACF stuff, this is using the relationship field within flexible content
Be the first to comment
You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.