So basically i have a main page and a footer page. Both are seperate .php files.

Im using ACF for this site.

Following the documentation, ive created a while loop for my 'flexible content' in the main page and it works, displaying all the data that gets looped and hooked from the CMS input fields.

My Problem is in the footer, i have a while loop that displays links, but it wont display unless i remove the while loop from the main page, then the links display in the footer.

I honnestly dot get why this happens ive tested allot and get my head wrapped around this, please help.

Main page code:


// check if the flexible content field has rows of data
if( have_rows('flexible_content_field_name') ):

    // loop through the rows of data
    while ( have_rows('flexible_content_field_name') ) : the_row();

        // check current row layout
        if( get_row_layout() == 'gallery' ):

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

                echo '<ul>';

                // loop through the rows of data
                while ( have_rows('images') ) : the_row();

                    $image = get_sub_field('image');

                    echo '<li><img src="' . $image['url'] . '" alt="' . $image['alt'] . '" /></li>';


                echo '</ul>';




else :

    // no layouts found


<?php get_footer(); ?>

Footer Code:

<div class="links">


            if( have_rows('footer_page_links', 'option') ): 
            while( have_rows('footer_page_links', 'option') ): the_row();


            <p><a href="<?php the_sub_field('footer_link');   ?>"><?php the_sub_field('footer_link_name'); ?></a></p>

        <?php endwhile; ?>
        <?php endif; ?>   

<?php wp_footer(); ?>

I would just like to add , not even the vardump() displays in the footer if main page while loop is implemented so it never gets inside the footer loop. The footer uses ACF option page - > LINK

Also all other option fields in footer displays, if its not within the while loop. I have removed the main page while loop then the footer while loop works, and this only happens with flexible content, my other pages with loops, that does non consists of flexible content works perfectly.

1 Answer 1


Looks like you need to add 'option' to your footer the_sub_field() calls:

<p><a href="<?php the_sub_field('footer_link', 'option'); ?>"><?php the_sub_field('footer_link_name', 'option'); ?></a></p>

var_dump() is used to dump a variable, not a string, so you would need to do something like var_dump($test) for that line to work. You are probably getting errors and warnings in your PHP log files - if not, you could turn on WP Debug to help figure out which lines of code are causing issues.

  • Hi Thanks for help, so if you look at docs from ACF, you dont need 'option' for the sub-fields, also adding it does not resolve issue. The vardump i added a string just to see if it enters the if , on the other pages my vardump string shows up. Then for the WP Debug thanks for that i have tried it and for the pages i dont see the links in the footer it shows no errors, which makes me think this is an ACF bug?
    – Ylama
    Jul 4, 2018 at 7:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.