Home › Forums › ACF PRO › Customize Relationship 1 result › Reply To: Customize Relationship 1 result
This can be solved by adding a counter. I have only included the loop and not all of your required code:
<?php
function magazine_featured_articles() {
?>
<div class="fa_grid ">
<div class="fa_wrapper wrap grid-4">
<?php
$featured_posts = get_field('featured_posts_field', 'options');
if ($featured_posts) {
global $post;
$count == 0;
foreach ($featured_posts as $post) {
if ($count == 1) {
// first small image
// need to insert this
echo '<div class="fa-grid-scroll">';
}
?>
<div class="fa_module <?php
if ($count == 0) {
echo 'fa-big-thumb';
} else {
echo 'fa-small-thumb';
}
?>">
<?php
setup_postdata($post);
// the rest of code for displaying each image here
?>
</div>
<?php
$count++;
} // end foeeach featured post
wp_reset_postdata();
// if the count of images > 1 then .fa-grid-scroll was inserted
// need to close it
if ($count > 1) {
echo '</div>';
}
} // end if posts
?>
</div>
</div>
<?php
}
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.