Home › Forums › Front-end Issues › subfields loop › Reply To: subfields loop
UPDATE
So i have had a look around on the documentation and tried a few things in which im half successful
I used the_sub_field(sub_field_name) which outputs all of the rows but they output like an array would do, just all text and it displays in one big chunk above everything and if i change it to get_sub_field it only pulls in one row for each post but displays correctly
here is the updated code
function my_custom_giveaways($content){
$giveawayQuery = new WP_Query(array(
'post_type' => 'giveaways'
));
global $post;
$giveawayResult = '<div class="cgBox">';
$giveawayResult .= '<div class="cgBox-inner">';
$giveawayResult .= '<div class="cgBox-wrapper cgBoxes">';
if ( $giveawayQuery->have_posts() ) : while ( $giveawayQuery->have_posts() ) : $giveawayQuery->the_post();
$theID = $post->ID;
if ( have_rows('my_giveaways') ) : while ( have_rows('my_giveaways') ) : the_row();
$giveawayBoxes = '<tr>
<td class="iconMid"><img src="' . the_sub_field('prize_icon') . '" width="25" height="25" alt=""></td>
<td class="thePrize">' . the_sub_field('place') . '<br>' . the_sub_field('prizes') . '</td>
</tr>';
endwhile;
endif;
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.