Help topics

Nest entries under parent entries

Use a parent model when one entry belongs inside another, such as chapters inside a book. Each chapter then has one parent book, and the API can list the chapters of that book.

Before you start

  • You need the administrator role.
  • The parent model must be a node model. The Can be placed under list shows node models only.
  • The child model must already exist and must be a node model. Only node models have the Advanced tab.

Set the parent models

  1. In the sidebar, select Models.
  2. Open the model for the child entries, for example a model named chapter.
  3. Select Advanced.
  4. In Can be placed under, select each model that can be the parent. For example, select the book model.
  5. In Moving, select one option. The Moving field appears after you select a parent model. Warning: With Entries stay under their parent (faster for huge trees), saving an entry with a different parent fails. Select Entries can move to another parent if editors must move entries.
    • Default: entries stay under their parent.
    • Entries can move to another parent: an entry can be moved to a different parent.
    • Entries stay under their parent (faster for huge trees): an entry cannot be moved to a different parent.
  6. Optional: In Parent, select Required to refuse entries that have no parent. The default is Optional.
  7. Select Save changes.

Result: The entry editor shows a Parent property for entries of this model. Choose the parent entry there.

List the children of a parent

Send a GET request with the parent's id in the parent parameter. Replace boo_… with the id of your parent entry.

curl "https://example.com/wp-json/morphic/v1/items/chapter?parent=boo_…"

Result: The response lists the chapter entries under that parent.