Advanced Custom Fields nested repeaters output

Hi!

I’m slowly getting to understand ACF and nested repeaters, but I am having trouble displaying it on my site.

The “Menu Sections” displays, but I must be doing something wrong with the menu items, because it wont display them…

This is what I have in a code block:

https://pastebin.com/6Nid7kVd?fbclid=IwAR3LOdsoqmk-zVET_cWn725zxfW5FiSvAbZ_KDzwly3zTFNkAQsroFv5v8g

Thankful for any tips !

It displays “Ingen retter funnet” which is norwegian for “No dishes found”, even though I have added dishes. So I think there must be something I did wrong in the second section of php…

Code posted were would help. I dont have access to pastebin while at work.

<?php

// check if the repeater field has rows of data
if( have_rows('menu_sections') ):

 	// loop through the rows of data
    while ( have_rows('menu_sections') ) : the_row();?>

		<h2>
        <?php the_sub_field('section_title');?>
		</h2>  

<?php if(get_sub_field('menu_description')) ?>


  
<?php
    endwhile;

else :

    echo "Ingen retter funnet";

endif;

    ?>

            <?php

            // check if the repeater field has rows of data
            if( have_rows('section_items') ):

                // loop through the rows of data
                while ( have_rows('section_items') ) : the_row(); ?>

                    <h3> 
                    <?php the_sub_field('rett_navn'); ?>
                    </h3>
                    <p>
                    <?php the_sub_field('rett_beskrivelse'); ?>
                    </p>
                    <p>
                    <?php the_sub_field('rett_allergener'); ?>
                    </p>
                    <p>
                    <?php the_sub_field('rett_pris'); ?>
                    </p> 

    <?php
            endwhile;

        else :

          echo "Ingen rader funnet";

        endif;

        ?>

Is this okay to read? Didnt find an option to paste raw code.

thank you in advance!

Okay, this is WordPress…

Based on what the code is and what you said, I would check the DB and see what the repeater name is listed as; if it isn’t exact, then it would cause 0 rows to be returned.

Yes, sorry for not specifying that. I got some tips that I was closing an opening an “if” without closing the first loop… if that makes sense to you, hehe

Sponsor our Newsletter | Privacy Policy | Terms of Service