Skip to content

Table of Contents: Includes headings outside of post content in template view #69359

@ryelle

Description

@ryelle

Description

The Table of Contents block pulls in every heading on the page, including headings outside the page content when in "Show template" view. I expected the ToC to only show content on the page. I even tried the "Only include current page" toggle, but it still included the footer content. This was only fixed by disabling "Show template" view, but since that doesn't persist I need to keep changing it.

Step-by-step reproduction instructions

  1. Set up a page template with headings in the template, for example the footer
  2. Write a page with headings
  3. Add a Table of Contents block
  4. With the page in "template view", the headings in the footer are included in the list
  5. Switch off "Show template" and the footer headings disappear

Whichever state the ToC is in when it's saved is what appears on the frontend.

Screenshots, screen recording, code snippet

Image

Toggling the template view, you can see the Footer items disappear:

toc-toggle-template.mp4

Environment info

  • WordPress 6.7.2
  • GB 20.3.0
  • Firefox & MacOS

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions