How to get the outline of a post?


like above, I want build it for my theme


As far as I understand your requirement, you want to show a “table of content” above your each post.
You can do this by using JavaScript.
The concept is, loop through your post content and get all the headings. Generate a ordered or un-ordered list of those headings and inject that above the content.

There is a good article on css-tricks you can check that.


Thank you very much !