I worked this out in the end, just in case anyone else is looking for this here’s what I did:
<?php if( have_rows('quote') ):
$quotes = get_field('quote');
if( count($quotes) == 1 ) { ?>
while ( have_rows('quote') ) : the_row(); ?>
..... etc
Thanks so much for your help John.
That will do it!
Thanks for your reply John.
I would like to format and style the first 2 values differently from the rest.
So the code would be something along the lines of:
<?php
$featured_posts = get_field('test_post_object');
if( $featured_posts ): ?>
<ul>
<?php foreach( $featured_posts as $post ):
if (value == 1|2){ ?>
<div class="bluebg">
<div class="section-inner">
<h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
<?php the_post_thumbnail('medium'); ?>
</div>
</div>
<?php } else { ?>
<div class="section-inner">
<h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
<?php the_post_thumbnail('medium'); ?>
</div>
<?php } ?>
<?php endforeach; ?>
<?php endif; ?>
If this isn’t possible, I know I can achieve what I want using the repeater field, but this would be much simpler to use.
Thanks for your help!
Perfect!
Thank you so much – that’s just what I needed.
Ok, thanks for letting me know…
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 Privacy Policy. If you continue to use this site, you consent to our use of cookies.