Support

Account

Home Forums Gutenberg Display only child pages in a relationship field within a block

Unread

Display only child pages in a relationship field within a block

  • Is it possible to modify the relationship field to display only child pages of the current page within a block?

    Using this filter ‘acf/fields/relationship/query’ I don’t know how to pass the current page id, because within the block $post_id is null.

    add_filter(‘acf/fields/relationship/query/name=child_pages’, function( $args, $field, $post_id) {
    // only show children of the current post being edited
    $args[‘post_parent’] = 2190;

    return $args;
    }, 10, 3);

Viewing 1 post (of 1 total)

The topic ‘Display only child pages in a relationship field within a block’ is closed to new replies.