Home › Forums › General Issues › Add number to Post Object values › Reply To: Add number to Post Object values
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!
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.