Support

Account

Home Forums Add-ons Repeater Field Pass Value to Nested Repeater

Solved

Pass Value to Nested Repeater

    • jarvis

    • August 7, 2014 at 7:50 pm

    Hi All,

    Really hope someone can help

    I’ve setup a Repeater and a Nested Repeater

    Repeater = FAQs
    This consists of:
    – Category (text field)
    – Q&A (repeater)

    The Q&A repeater then has:
    – Question (text field)
    – Answer (Text Area)

    The idea is to then bunch all questions by category type. I’m then using some jquery etc to make it more engaging but that’s an aside!

    What I can’t seem to do is pass the value of category into the nested repeater like

    Here’s my code but I can’t see what I’m dong wrong? Any help is appreciated:

                      <?php if(get_field('faqs')): while(has_sub_field('faqs')): ?>				  
    					<?php $variable  = get_sub_field('category'); ?>			  
    
    					  <?php if(get_sub_field('qa')): while(has_sub_field('qa')): ?>
    						  <?php $variable  = get_sub_field('category'); echo $variable; ?>
    						  <article class="envor-sorting-item <?php the_sub_field('category'); ?>">
    							<header><?php the_sub_field('question'); ?> <i class="fa fa-plus"></i></header>
    							<p><?php the_sub_field('answer'); ?></p>
    						  </article>
    					  <?php endwhile; endif; ?> 				  
    				  
    				  <?php endwhile; endif; ?> 
    • jarvis

    • August 7, 2014 at 9:56 pm

    Solved it with this:

                      <?php if(get_field('faqs')): while(has_sub_field('faqs')): 				  
                      $variable = get_sub_field('category'); 			  
                      if(get_sub_field('qa')): while(has_sub_field('qa')): ?>
    						  
    					<article class="envor-sorting-item <?php echo $variable; ?>">
    						<header><?php the_sub_field('question'); ?> <i class="fa fa-plus"></i></header>
    						<?php the_sub_field('answer'); ?>
    					</article>
    						  
                      <?php endwhile; endif; 
                      endwhile; endif; ?>

    Not sure what I was doing wrong before!! Hopefully it helps someone else

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.

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.