Skip to content

How to Exclude a Title from a Table of Contents in WordPress?

Key Takeaways

  • Nexter Blocks Table Of Contents block excludes a heading by adding the CSS class “js-toc-ignore” in the Advanced tab’s Additional CSS class(es) field.
  • Table Of Content widget uses the Layout tab to select the appropriate type and style before a heading is excluded.
  • Multiple headings are excluded from the table of contents after the page is updated and refreshed.
Table of Contents

Not every heading belongs in the outline — a Related posts or About the author heading is noise in a list of what the article covers.

One CSS class on a heading keeps it out of the list while leaving it on the page exactly as it was.

For every Table of Contents setting in one place, see the Table of Contents block guide.

Before You Start

  • Edition: Pro — the Table of Contents block is part of Nexter Blocks Pro.
  • Block to enable: Table of Contents, switched on under Nexter > Blocks in your WordPress dashboard.
  • Real headings on the page: the list is built from your H1–H6 blocks, so text that only looks like a heading will not appear.

Steps

  1. Open the post and click the heading you want left out.
  1. In the block sidebar, open the Advanced section.
  1. Type js-toc-ignore into Additional CSS class(es).
  1. Update the post, then reload the page — the heading is still there, but gone from the list.

The class goes on the heading, not on the Table of Contents block. Repeat it on as many headings as you like.

How It Behaves

  • The heading stays on the page. The class only tells the list to skip it — measured with six headings, where adding the class to one left five links and the heading still visible in the article.
  • Its sub-headings are not skipped with it. Only the heading carrying the class is left out, so an H3 below an ignored H2 still appears.
  • It works on any heading level.
  • Removing the class puts the heading straight back in the list.

Other Ways to Shorten the List

If you want to leave out…Do this instead
Every heading of one level, such as all H4sSwitch that level off under Headings in the Content panel
Everything outside the article, such as a sidebarPoint Content Selector at the article wrapper, for example .entry-content
One particular headingThe js-toc-ignore class above

Limitations

  • Pro only.
  • The class has to be spelled exactly js-toc-ignore. Anything else is ignored silently, with no warning in the editor.
  • There is no setting for this in the Table of Contents block itself — it is always done on the heading.
  • If several headings share a reusable pattern, the class travels with the pattern everywhere it is used.
  • One per page. With two Table of Contents blocks on the same page only the first one is filled in — the second stays empty. This was measured on the front end.

Troubleshooting

The heading is still in the list

Check the spelling, and check the class is on the heading block rather than a group or column around it.

The heading disappeared from the page as well

That is not this class. Something else — another CSS class or a visibility setting — is hiding it. js-toc-ignore has no effect on how the heading looks.

I want to leave out several headings at once

Add the class to each one, or use the alternatives in the table above.

Related Docs

Share your Thoughts

Still in Doubt? Let’s Assist You

Have Feedback or Questions?

Join our WordPress Community on Facebook!