How do you add a table of contents to WordPress posts without a plugin?
In short: In Wiozen Theme's Guide design the table of contents comes built into the post template: it turns the post's H2 headings into a numbered list and gives each heading a link target (anchor) on its own. If the post has fewer than three H2s, the list doesn't show. In the other designs (News, Technology, Finance, Food) the plugin-free way is to give each H2 a name in its Advanced › HTML anchor field and put a list linking to those names at the top of the post.
How does the contents list work in the Guide design?
The Guide design's post template holds the theme's Contents block, so you don't add anything to the post. The block reads the post text and lists the H2 headings in order as a numbered list. H3 and smaller headings aren't included.
- The list comes with an "In this article" heading and a count of the sections.
- If the post has fewer than three H2s, the block prints nothing. A short two-section post doesn't carry a pointless contents box.
- On desktop the list sits to the left of the post and stays in place as the page scrolls. The section being read is highlighted in the list.
- On phones (760 pixels and below) the list sits above the text as a closed box that opens on tap.
- If you split the post into pages with
<!--nextpage-->, the list only shows the headings on the page being read.
Where do the heading links (anchors) come from?
The Guide design builds an anchor for each H2 from the heading text: a "Setup steps" heading becomes #setup-steps, and if the same text appears again -2 is added. That lets you copy and share a link to a single section.
If you later change the heading text, the generated anchor changes too, and a section link shared earlier lands at the top of the post. For headings whose link should stay fixed, enter your own name in the Heading block's Advanced › HTML anchor field. The theme uses an anchor you set by hand as it is.
What happens to the Rank Math or Yoast contents block?
If you also added an SEO plugin's contents block in the Guide design, the page doesn't show two lists. The design hides the Rank Math and Yoast contents blocks and turns the "Table of contents" heading inside them into a paragraph, so that heading isn't counted as a section in the theme's list. You don't need to delete the plugin block from older posts.
This only applies to the Guide design. In the other four designs the plugin's contents block shows as usual.
A contents list in the News, Technology, Finance and Food designs
These designs have no contents list in their post template and don't add anchors to headings on their own. The theme's Contents block may show up in the inserter, but these designs don't style it. The cleanest plugin-free way is to build it by hand with WordPress's own blocks:
- Select each H2 heading and enter a short name in Advanced › HTML anchor in the settings sidebar, for example
setup. - Add a List block at the top of the post, after the first paragraph.
- Type each heading's text as an item, select it and enter the anchor, such as
#setup, as the link. - Preview the post and click each link to check it jumps to the right section.
A hand-built list doesn't update when a heading changes; if you add or remove a section, fix the list too. If you have many long posts, an SEO plugin's contents block does this automatically.
Does a table of contents help with AI answers?
A contents list on its own doesn't make a page quotable. What helps is the structure behind it: each H2 answering one sub-question, with the answer right under the heading. For post structure, dates and sources, see how to build a guide site that AI answers cite.
Frequently asked questions
Can I add H3 headings to the contents list?
The Guide design's list only takes H2 headings. If you want a subheading in the list, make it an H2.
Why doesn't my post show a table of contents?
In the Guide design the post needs at least three H2 headings. Check that they really are Heading blocks at H2 level, not bold text in a paragraph block.
Does the contents list slow the page down?
The list is built on the server as HTML and loads no images or external files. The small script that highlights the current section only loads on single posts and pages in the Guide design.
For a post template with the contents list built in, download Wiozen Theme for free and pick the Guide design.