Search code examples
phpwordpressadvanced-custom-fieldsacfpro

Use repeater inside repeater


I want to know what's wrong with this code, it's not displaying the second repeater (that one inside the first repeater):

<?php
    $post_links = get_field("box_download");
    if ($post_links) {?>
    <div>  <?php
        foreach($post_links as $link){?>
            <div style="download-box">
                <?php if(!empty($link['season'])){?>
                <span class="title"> فصل : <span class="title-content"><?php echo $link['season']?></span></span><?php }; ?>
                <?php if(!empty($link['episode'])){ ?>
                <span class="title"> تعداد قسمت ها :<span class="title-content"><?php echo $link['episode']?></span></span><?php }; ?>
                <?php if(!empty($link['resolution_serie'])){ ?>
                <span class="title"> کیفیت :<span class="title-content"><?php echo $link['resolution_serie']?></span></span><?php }; ?>
                <?php if(!empty($link['average_size'])){ ?>
                <span class="title"> میانگین حجم :<span class="title-content"><?php echo $link['average_size']?></span></span><?php }; ?>
                <?php if(!empty($link['encoder_serie'])){ ?>
                <span class="title"> انکودر :<span class="title-content"><?php echo $link['encoder_serie']?></span></span><?php }; ?>
            </div>
            <div class="links">
                <?php 
                    $post_something = $link['links'];
                    echo $post_something['field_name'];
                ?>
            </div>


        <?php };

?>

</div>
<?php }; ?>

It's not displaying the $post_something['field_name']


Solution

  • $link['links'] is an array, you should add the index you want to access or use loop for it.replace $post_something = $link['links']; with $post_something = $link['links'][0];