Home › Forums › Front-end Issues › How to get the data outside the loop? › Reply To: How to get the data outside the loop?
Without knowing the exact index of each nested repeater it will be impossible to get a value from a specific nested sub field with such a complex setup. But in order to loop through this structure outside of the loop is to provide the post ID for the first
if (have_rows('page', $post_id)) {
while (have_rows('page', $post_id)) {
the_row();
// nested loops here
}
}
If you do know the exact index at each lever you can use get_post_meta() as suggested by @willh, this is how the meta key can be constructed. nested field indexes start at 0 and not 1.
$meta_key = "page_{$index}_row_{$index}_columns_{$index}_elements_{$index}_field_name";
$value = get_post_meta($post_id, $meta_key, true);
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.