History of the malfunction
This is a memo regarding an anchor link issue I encountered with the WordPress plugin "Table of Contents Plus".
Clicking on the anchor links (in-page links) in the table of contents generated by "Table of Contents Plus" will take you to the corresponding section of the article.
The other day, when I casually clicked on the table of contents within my own article, I encountered a problem where it didn't jump to the heading that served as the anchor point.
I hastily checked other pages and it turned out that anchor links were not working on any of them.
I hadn't changed any settings, so I investigated various possibilities and discovered that the cause was the table of contents function of the "Cocoon" theme I'm using for this blog.
I am writing this article as a memo about this experience.
Direct cause
The "Table of Contents Plus" plugin sets anchor points in the following format for the headings to which you jump:
(In the default settings)
<Span ID="i"">PrefaceSpan>
The links in the automatically generated table of contents are designed to jump to this specific point.
However, if you have the table of contents function of "Cocoon" turned on, anchor points will be automatically generated in the following format for each heading you jump to.
<Span ID="toc1"">PrefaceSpan>
In this case, the source and destination links generated by "Table of Contents Plus" do not match, so clicking on an item in the table of contents will not take you to the corresponding location.
(Of course, clicking within the table of contents generated by Cocoon will jump to the relevant section without any problems.)
Solution
I solved the problem by selecting the "Table of Contents" tab in the "Cocoon" settings and unchecking the "Show Table of Contents" box.
In short, the solution is to ensure that only the "Table of Contents Plus" plugin is running.
Alternatively, you could simply use Cocoon's built-in table of contents function and disable "Table of Contents Plus."
You should use whichever one you prefer.
In my case, I decided to continue using "Table of Contents Plus" for the reasons I will explain later.
Reasons for the delayed discovery
The cause of this issue was that Cocoon's table of contents function and "Table of Contents Plus" were overlapping.
Normally, if these two overlap, two tables of contents with different designs would appear in the main text, which should be immediately noticeable.
Why didn't I notice?
One of the conditions for Cocoon's table of contents feature to be inserted is that "there must be an h2 heading in the main text."
I usually only use "h3," "h4," and "h5" headings in my articles, and there are very few articles that contain "h2" headings in the body text.
Therefore, even though Cocoon's table of contents function was turned on, most articles only displayed the "Table of Contents Plus" table of contents, and visually, there was nothing wrong.
If you ask me why I start with "h3," I can only say it's a long-standing habit.
Thinking back, I believe the reason was that having an extra level of spacing in the heading hierarchy makes it easier to revise the structure of the main text later on.
Due to these specific circumstances, the discovery was delayed.
Under normal circumstances, I think the problem would have been discovered immediately if someone had noticed something strange, like, "Hey, there are two table of contents!"
I apologize for any inconvenience caused to visitors to the page while I was trying to notice the issue.
I would like to take this opportunity to offer my deepest apologies.
Side note: Why I use "Table of Contents Plus" instead of Cocoon's built-in table of contents function
This time, I was able to properly learn about Cocoon's table of contents function.
Considering which table of contents is better,I prefer the design and functionality of Cocoon's table of contents.
Therefore, this incident has made me consider switching from "Table of Contents Plus."
However, there was one problem when I tried to switch trains.
This summary pageIf you have linked pages directly to headings within the main text, as shown above, switching to Cocoon's table of contents feature will invalidate those links.

Within this blog, only a few summary pages use this type of linking method.
I suppose I could correct each of those pages individually, but I thought it would be a bit of a hassle.
Basically, it's best to avoid using plugins if possible.
If you're not using it in this way, I think it's smarter to switch from "Table of Contents Plus" to Cocoon's built-in table of contents feature.
Thank you! I was having the same problem with the links not working, but after unchecking the checkbox, I was able to jump to the relevant section from the table of contents.
Thank you for your comment.
I'm glad I could help solve your problem!
I was experiencing the exact same phenomenon and wondering why, but thanks to you, it's now resolved.
thank you!
Thank you for your comment.
Since I couldn't find any solutions to similar problems through searching, I decided to write this article, even though it might be a niche issue.
I'd be happy if this was helpful to even one person!