I am really not sure how to write the code. How do I get all the headings from the page? To be specific, core/heading. I wanted to make a sidebar so that the user can just jump from one section to another. Please see the image below.

enter image description here

  • 1
    You mean an outliner or table of contents? Such a block already exists in Gutenberg as part of the full site editing initiative, you can see its source code here github.com/WordPress/gutenberg/tree/trunk/packages/…
    – Tom J Nowell
    Apr 5, 2021 at 15:37
  • Hi Tom. Thanks for the response. Yes, like table of contents. How do I find every heading(core/heading), add ID, and add heading link to sidebar.
    – ddd
    Apr 6, 2021 at 8:24

1 Answer 1


Update on this. I got the answer! I followed this simple code from https://goran-s.in.rs/table-of-contents-wordpress-without-plugin/

It's working fine!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.