Support

Account

Home Forums Add-ons Repeater Field Repeater + Multiple Values

Helping

Repeater + Multiple Values

  • Hi guys!

    I bought the acf pro today and build up some custom fields. Now I have a tricky task.

    I want to dislplay a meal plan on 2 pages… one page for Paleo and the other for Low-Carb. Check the attachment and you will see how I build up the repeater fields.

    In the end it should look like this on each page (e.g. Paleo):

    Day 1: Egg Muffin Melt
    Day 2: Feta Scrumbled & Chicken Mozzarella Sticks
    Day 3: Cauliflower Rice
    Day 4: Egg Muffin Melt & Cauliflower Rice
    ….
    Day 7: …

    I have to show the title of the “meal” and clickable (link). When there is more than one dish, it should have a “&” in between.

    Second, I want to divide them in weeks:
    Day 1: …
    Day 2: …

    Day 7: …

    DIV Section with headline

    Day 8: …

    Day 14: …

    DIV Section with headline

    Because I display the repeater field on different pages, I think, I also have to get the data with the ID.

    For me the whole thing is a little bit too tricky. I hope somebody can help me!?!?

    Thx

  • Hi @dseiner

    Please use the code tags to post code sampels in the future.. makes our lives easier 🙂 It seems your attachment is missing as well.

    I would suggest that you have two different repeaters. One for paleo and one for low carb. That way it’ll be easy for you to separate them into different pages.

    As for separating the rows in weeks you can just have a counter and begin a new section for each 7th row.

    Something like:

    
    <?php if( have_rows('repeater') ): ?>
    	<?php 
    	$row_count = get_field('repeater');
    	$i = 0; ?>
    	<div class="week-section">
    	<?php while( have_rows('repeater') ): the_row(); ?>
    		<?php 
    		$i++;
    		if( $i % 7 == 0 ): ?>
    			</div>
    			<div class="week-section">
    		<?php endif; ?>
    		
    		Some content
    		
    		<?php if( $row_count == $i ): ?>
    			</div>
    		<?php endif; ?>
    	<?php endwhile; ?>
    	
    <?php endif; ?>
    
Viewing 2 posts - 1 through 2 (of 2 total)

The topic ‘Repeater + Multiple Values’ is closed to new replies.