I tend to write long blog posts, but it’s a pain to add a table of contents. Not anymore! Let AI take care of that for you.
Prompt
“Generate a table of contents from the h2s in this blog post. Don’t change anything else in the post. Just create an h2 that says ‘Table of Contents’ and add the ToC to it as well as the anchors above each of the h2s. Don’t use a list, just paragraph text.”
Tip: To access the code editor in WordPress, click the 3 dots to the right of the Publish button, then select Code editor.

Model
I tested this prompt using Claude Opus 4.
Result

It even matched the html style WordPress uses.
