Home › Forums › Backend Issues (wp-admin) › How to print values from groups within groups
I am trying to print a list of Committee Members. I have a group called com_members and then a group for each member that contains title, text and image. What is the most efficient way of printing this information on my WordPress page? At the moment I have the following. Is there a more efficient way of writing this? Anyone know? I am using Advanced Custom Fields free edition.
<?php
if( have_rows('com_members') ):
while ( have_rows('com_members') ) : the_row();
if( have_rows('member1') ): //?????
while ( have_rows('member1') ) : the_row();
echo "Member 1 <br/>";
$title = get_sub_field('title');
echo $title . "<br/>";
$image_url = get_sub_field('image');
echo $image_url . "<br/>";
$text = get_sub_field('text');
echo $text . "<br/>";
endwhile;
else:
//nothing
endif;
if( have_rows('member2') ): //?????
while ( have_rows('member2') ) : the_row();
echo "Member 2 <br/>";
$title = get_sub_field('title');
echo $title . "<br/>";
$image_url = get_sub_field('image');
echo $image_url . "<br/>";
$text = get_sub_field('text');
echo $text . "<br/>";
endwhile;
else:
//nothing
endif;
if( have_rows('member3') ): //?????
while ( have_rows('member3') ) : the_row();
echo "Member 3 <br/>";
$title = get_sub_field('title');
echo $title . "<br/>";
$image_url = get_sub_field('image');
echo $image_url . "<br/>";
$text = get_sub_field('text');
echo $text . "<br/>";
endwhile;
else:
//nothing
endif;
endwhile;
else :
// no rows found
endif;
?>
There is an answer at stack overflow:
You must be logged in to reply to this topic.
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.