Support

Account

Home Forums Add-ons Repeater Field Repeater From Another Page

Solved

Repeater From Another Page

  • So I’m using the $other_page to set a page ID but I need to use it in a repeater in my page template:

    <?php 
    
    $other_page = 934;
    
    $rows = get_field('myrepeater', $other_page);
    
    if($rows)
    {
    	foreach($rows as $row)
    	{
                 echo '<div class="toggle"><h3><a href="#">' . get_sub_field('current_month') . '</a></h3>
    		<div> Shortcode will be in here </div></div>
    		<a href="https://example.com/' . get_sub_field('field_url') .'&output=csv">Download CSV</a></div>';
    	}
    } ?>
     
    <?php endif; ?>

    it breaks the page. Any ideas anyone? Would be appreciated.

  • Hi @phil.owen

    The get_sub_field function can ONLY run within a have_rows or has_sub_fields while loop!
    Please read the docs to get a better understanding for this.

    Thanks
    E

  • Yeah I got it working now. Thanks man.

Viewing 3 posts - 1 through 3 (of 3 total)

The topic ‘Repeater From Another Page’ is closed to new replies.