skip to Main Content

My code

<?php if( have_rows('mir_global_header') ): ?>
<div id="mid-bg1">
    <div id="top-container1">
        <?php while( have_rows('mir_global_header') ): the_row();
                        $count = get_row_index();
                        $header_image = get_sub_field('header_image');
                        $header_image_text = get_sub_field('header_image_text');
                        ?>
                        <img src="<?php echo $header_image; ?>" id="<?php echo $count; ?>" alt="<?php echo $header_image_text; ?>" />
        <?php endwhile; ?>
    </div>
</div>
<?php endif; ?>

enter image description here

enter image description here

I’ve done everything as mentioned in the documentation. It’s not working. Is it because ACF pro is not activated? Is there any other way to do this? Thanks in advance

2

Answers


  1. Are your fields in an options page or a classic post_type?

    Test this for print a result

    $mir_global_header = get_field('mir_global_header');
    echo '<pre>';
    print_r($mir_global_header );
    echo '</pre>';die();
    

    PS : ACF Gallery gives the same result 😉
    https://www.advancedcustomfields.com/resources/gallery/

    Login or Signup to reply.
  2. If you’re using ACF options page. You have to specify that in the have_rows. https://www.advancedcustomfields.com/resources/get-values-from-an-options-page/

    <?php if( have_rows('mir_global_header', 'option') ): ?>
        <div id="mid-bg1">
            <div id="top-container1">
                <?php while( have_rows('mir_global_header', 'option') ): the_row();
                    $count = get_row_index();
                    $header_image = get_sub_field('header_image');
                    $header_image_text = get_sub_field('header_image_text');
                    ?>
                    <img src="<?php echo $header_image; ?>" id="<?php echo $count; ?>" alt="<?php echo $header_image_text; ?>" />
                <?php endwhile; ?>
            </div>
        </div>
    <?php endif; ?>
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search