Table of contents plugin

The Easy ToC plugin (and others I have come across that do the same thing) has major accessibility issues. I have written my own code to use the details and summary html tags instead.


Have you made that code available anywhere @timkaye? And could you recommend any non-Gutenberg ClassicPress only theme?

I haven’t made it available so far. I’m not against doing so, but I’ve built it to integrate tightly with the sites on which it’s used, so it’s not something you could just install, activate, and you’d be ready to go. (There’s no JavaScript involved; everything works server-side via PHP.)

Here’s an example of the code in action: Stetson University College of Law - Florida's First Law School If you browse that page on a narrow screen, like a phone, you’ll see the code working automatically. If you browse it on a wider screen, you’ll see the shortcode at work inside a widget.

To make it work for you, you’d almost certainly to edit the main file a little, and then you’d need to upload that file (and a folder of files) to the mu-plugins folder. Then you’d need to re-save every post where you want to use this. You might also need a little CSS to make it fit in with your theme.

As for themes, I’d recommend anything built by Sami Keijonen: He’s no longer supporting them these days, but they are so well coded that anyone can update them if necessary. I still have a couple of sites running themes that are heavily based on his work.

1 Like

Is this the same plugin used on documentation site? I remember you helped with that.

(I moved this discussion into a separate topic)

No, I did think we might need it, but the code we ported over from WP came with some regex that does the ToC there. It works fine on the documentation site but, again, it’s tightly integrated with that site. Generally, it’s not recommended to parse HTML with regex. My code uses PHP’s own DomDocument, extended to work with HTML5, which is designed precisely to parse HTML.

1 Like

Hi @timkaye If I go with your Bedrock theme would your TOC code work in it? Or is it already in there?

I’m not a programmer / coder and neither are the other serious bloggers who most need to switch to Classic Press.

The TOC is not part of the theme. And I’m aware that most blogger aren’t coders. But the issue is how you create the headings within your posts. The plugins that exist do it the way they do so precisely that they can be used on generic content, but that means cutting other corners.

If you pick a theme and point me to your blog, I’ll see if I can tailor my code to your needs.

I’d love to pick a theme. My site is all but down because I cannot find a single Classic Press theme.

My site was using WP and the Easy Table of Contents plugin. It uses subtitles to create the TOC.

You can see what is limping along at and what it looked like before the crash here.

In case these details help:

  • The site was built in 2008

  • It was running Genesis with the StudioPress Centric Mobile Responsive Theme

It is now running on Classic Press without any theme because I cannot find one.

The theme there is working fine. The problem is you have a couple of inline style sheets left over from your previous theme. If you can find and delete them, your site should be fine.

1 Like

I think if you standardized headings using best accessibility practices and rolled it up into a plugin, everyone would be able to benefit from it and customize their content to be accessible and have proper ToC. Just a suggestion.

It’s not the output that’s the issue. It’s the input, which could take any form. It might well need a user configuration screen to allow for different settings. And then I’d have to support it.

Perhaps there are other options, but the TOC plugin bloggers commonly used simply creates a nested table using header types.

So it displays all H2 sub-titles and any H3 sub-titles indented under the H2 sub-title before them.

The plugin I’ve been using has controls to choose how many headers to include (H2, H3, H4, etc.) and apparently somewhere font sizes (because H3 was larger than H2 which is not good).

But honestly, a simple TOC that just displayed H2, H3 in a reasonable size would be what 90+% of sites would use.

The input issues aren’t restricted to the headings; I have seen quite a few sites with malformed HTML, which causes the parser to throw a fit.

But, with your and Viktor’s encouragement, I will see if I can make some time this week to come up with what you’re asking for.


That would be a popular plugin to add to the Classic Press plugins because it is long-form content writers who need a Table of Contents plugin.

And it is those writers who most detest Gutenberg because it is useless for writing and editing in.

I’m guessing that our HTML is ok because the Easy Table of Contents plugin works for us. I see it regularly on other long-form bloggers’ sites and ran it on mine.

If their HTML is malformed, it needs fixing. And that isn’t the plugins’ problem.

I agree that if the HTML is malformed, it shouldn’t be the plugin’s problem. But it will be blamed on the plugin nevertheless! Anyway, I’ll see what I can do.

1 Like

This one works fine for me:

1 Like

It’s not a question of “working”. It’s a question of accessibility. In other words, can disabled readers make use of it?


Ah, sorry. I missed this point

I have now built an initial version of the plugin. You can download it as a zip file from by hitting the green Code button. Then upload it to your site like any other plugin zip file.

It should “just work” when you activate it, but only on posts. You won’t need to re-save them to make it work. There is also a shortcode [kts_toc] you can put in a custom HTML widget if you want.

Fuller details are in the readme file.


Thank you, Tim. I sent the details to the developer working on my site. Is it listed in the ClassicPress plugins page? I’m sure others will be very interested in it.