Code Element Cp

ACF Relationship Field: Query Children of Current Page

Use this code snippet to query the current page’s children in an Advanced Custom Field Relationship Field.

Replace:

field_name: with the name of your ACF Relationship field

add_filter('acf/fields/relationship/query/name=field_name', function ($args, $field, $post_id) {
    // show only child pages of current page
    $args['post_parent'] = $post_id;		
    return $args;
}, 10, 3);