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)

You must be logged in to reply to this topic.

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 Cookie Policy. If you continue to use this site, you consent to our use of cookies.