Table of Contents

In this article

This block is experimental and may change or be removed without notice.

Summarize your post with a list of headings. Add HTML anchors to Heading blocks to link them here.

  • Name: core/table-of-contents
  • Category: design
  • API Version: 3
  • Block Type: Hybrid (static save + server enhancements)
  • Keywords: document outline, summary

Attributes

Defined via the attributes property in block.json.

Attribute Type Default Description
headings array []
onlyIncludeCurrentPage boolean false
maxLevel number
ordered boolean true

Supports

Defined via the supports property in block.json.

Block Markup

This is a hybrid block. It saves static markup that the server may enhance during rendering.

<!-- wp:table-of-contents {"headings":[{"content":"Heading text","level":2,"link":"#heading-id-1"},{"content":"A sub-heading","level":3,"link":"#heading-id-2"}]} -->
<nav class="wp-block-table-of-contents"><ol><li><a class="wp-block-table-of-contents__entry" href="#heading-id-1">Heading text</a><ol><li><a class="wp-block-table-of-contents__entry" href="#heading-id-2">A sub-heading</a></li></ol></li></ol></nav>
<!-- /wp:table-of-contents -->

Source