admin管理员组

文章数量:1296291

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.

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.

Share Improve this question asked Apr 5, 2021 at 15:09 dddddd 74 bronze badges 2
  • 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/WordPress/gutenberg/tree/trunk/packages/… – Tom J Nowell Commented 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 Commented Apr 6, 2021 at 8:24
Add a comment  | 

1 Answer 1

Reset to default 0

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!

本文标签: filtersWordPress Gutenberg coreheading block (wpblockheading)