Printing array from the current post and page is pretty straight forward. Similarly, printing repeater in the same post or page is relatively simple.
But when it comes to getting ACF fields values from another post, it becomes a bit tricky. Let’s go through some examples.
Printing a field from another post
Saving a field from another post to a variable
Getting repeater values from another post
For repeater values, the_sub_field and get_sub_field don’t need a post id parameter like the_field and get_field.
if( have_rows('repeater_field_name', $other_page) ): while( have_rows('repeater_field_name', $other_page) ): the_row(); the_sub_field('sub_field_1'); the_sub_field('sub_field_2'); $sub_field_3 = get_sub_field('sub_field_3'); //do something with the saved variable endwhile; endif;
ACF advanced custom pages post type posts repeater while