Home › Forums › Add-ons › Repeater Field › Can't seem to pull repeater sub fields in tamplate
I have a page with tabs that I created. I created a repeater field for the tabs with sub fields that have three sub fields inside:
Tabs (repeater)
— Tab Title (text)
— Tab Icon (text)
— Tab Content (repeater)
—- Is Resource (True/False)
—- Extras (checkbox)
—- Background Image (image)
—- Title (wysiwyg)
—- Column 1 (wysiwyg)
—- Column 2 (wysiwyg)
—- Resources (relationship)
Now I have a loop that I set with a variable ($content
) to create the tabs and that works. When I try to loop into the Tab Content
sub fields I get nothing. I have tried get_field();
, the_sub_field();
, get_sub_field()
and even $variable['sub_field_name'];
and nothing seems to work. When I’m in the foreach loop on the content with print_r($content);
I return ALL the subfield data to the screen but can’t get anything to come up in the code. Here is what I have for code:
<?php
global $tech_current_layer;
$layer = $tech_current_layer;
if(isset($layer['technology']) && !empty($layer['technology'])) {
$technology = $layer['technology'];
}
?>
<section id="technology">
<div class="technology_background">
<div class="technology_tabs_heading">
</div>
<div class="techn_tabs_container">
<section class="tabs">
<?php
$tabs = $layer['tabs'];
//var_dump($tabs);
if ($tabs):
?>
<ul class="tab-nav tech-section-tabs clearfix">
<?php foreach($tabs as $tab): ?>
<li class="<?php echo $tab['icon']; ?>"><span class="icon"></span><a href="#"><?php echo $tab['tab_title']; ?></a></li>
<?php endforeach; ?>
</ul>
<?php foreach($tabs as $tabclass): ?>
<div class="tab-content <?php echo $tabclass['icon']; ?> active">
<?php endforeach; ?>
<?php foreach($tabs as $content): ?>
<?php //print_r($content); ?> // THIS WILL OUTPUT THE DATA
// NOTHING BELOW WILL PRINT OUT DATA
<div class="<?php echo the_sub_field('extras'); ?>" <?php if(the_sub_field('background_image')): ?> style="background: url('<?php echo the_sub_field('background_image'); ?>" <?php endif; ?> >
<div class="row">
<div class="twelve columns">
<h1><?php echo the_sub_field('title'); ?></h1>
</div>
</div>
<div class="row">
<div class="six columns left-col">
<?php echo the_sub_field('column_1'); ?>
</div>
<div class="six columns right-col">
<?php echo the_sub_field('column_2'); ?>
</div>
</div>
</div>
<?php endforeach; ?>
<div class="first-tab-last">
<div class="row">
<div class="twelve columns">
<div class="techbutton">
<a href="" class="button">NEXT: <i class="fa fa-arrow-right"></i></a>
</div>
</div>
</div>
</div>
</div>
<div class="tab-content second-tab">
<div class="second-tab-last">
<div class="row">
<div class="twelve columns">
<div class="techbutton">
<a href="" class="button">NEXT: <i class="fa fa-arrow-right"></i></a>
</div>
</div>
</div>
</div>
</div>
<div class="tab-content last-tab">
</div>
<?php endif; ?>
</section>
</div>
</div>
</section>
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!
ACF wouldn’t be so widely used in WordPress if it didn’t have some pretty amazing capabilities. In this article, we look at a few of the features we’ll discuss during “7 things you didn’t know you could do with ACF” at #WPEDecode later this month. https://t.co/5lnsTxp81j pic.twitter.com/Yf0ThPG1QG
— Advanced Custom Fields (@wp_acf) March 16, 2023
© 2023 Advanced Custom Fields.
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 Cookie Policy. If you continue to use this site, you consent to our use of cookies.