Retrieve repeater sub field (image) from an Options Page – ACF

Question

I have a similar issue —
I made an ACF called Icon (post id is 348) and linked it to my Options Page called School Settings
Inside of Icon I have a field called School with a name (school_header) that is a repeater field
I am trying to loop through this repeater and school icons
These images will display in our custom header .php template as a list

Attempts:
We have tried to use the word ‘option’, ‘options’, and ‘icon’ instead of 348

Here is my code:

 <?php

if ( have_rows( ‘icon’, 348 ) ) : ?>
<?php while ( have_rows( ‘icon’, 348 ) ) : the_row();

        if ( have_rows( 'school_header' ) ) : ?>

        <ul>

               <?php
               while ( have_rows( 'school_header' ) ) : the_row();
                   $image = get_sub_field( 'school_icon' );
               ?>

            <li>
                <img src="<?php echo esc_url( $image['sizes']['thumbnail'] ); ?>" />
            </li>

               <?php endwhile; ?> 
        </ul>

           <?php endif; ?>
    <?php endwhile; ?>
0
sanne 4 months 0 Answers 16 views 0

Leave an answer