humanmade/hm-toc

WordPress plugin that adds anchors to headings in post content and generates table of contents from headings.

1.1.5 2024-09-27 14:38 UTC

This package is auto-updated.

Last update: 2024-09-27 14:39:08 UTC


README

WordPress plugin with the following features:

  • Generate table of contents that lists all headings (Ordered hierachically) in post content.
  • Automatically add anchors links after all headings in post content.
  • Block to add these to pages and template.
  • Adds 'active' class to the current heading in the table of contents.

FAQ

I don't want to automatically add anchor links to headings.

You can remove the filter that adds these with the following snippet. Doing it like this means that the plugin will still ensures headings all have IDs.

// Don't append an anchor link to each heading.
add_filter( 'hm_toc.contents.anchor_html', '__return_empty_string' );