We've retired the forum in favor of GitHub Discussions.

New conversations can be started on GitHub. Existing conversations will remain for a while longer.

Head over to GitHub →

How to get the child entries of current using Statamic\Entries\Entry object?

John Carter November 2, 2020 by John Carter

If I have a parent entry ID and want to get the direct children entries of the current entry. How do I do that?

I have an Statamic\Entries\Entry object from an Statamic\Events\EntrySaved event.

I can get an array of the collection tree, which I can then filter, but this seems a bit convoluted?

info(print_r($event->entry->structure()->in('default')->tree(), true));

The other thing I have considered is to add an Entry field in the blueprint called my_parent or something then use:

    ->where('my_parent', 'e2af94d1-12b1-4934-bf94-b368b227cfce')

But again, this seems ridiculous?

>>>>>>> Unanswered <<<<<<<
2 Replies