Home › Forums › ACF PRO › Running recursive querys › Reply To: Running recursive querys
Using an ACF relationship field to get children
function recursive_children($parent_id) {
children = get_field('relationship_field', $parent_id);
if ($children) {
foreach ($children as $child) {
// do some stuff with child
// recurse this child
recursive_children($child->ID);
// do some other stuff with child
}
}
}
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.