Hi,
a wrapper div is only being added if you set a custom class. When you add a new and default SimpleTOC block into the content, it will look like this:
<h2 class="simpletoc-title">Table of Contents</h2>
<ul class="simpletoc-list">
<li><a href="#123">123</a></li>
<li><a href="#123">123</a></li>
<li><a href="#123">123</a></li>
<li><a href="#123">123</a></li>
</ul>
There is no “wrapper”.
-
This reply was modified 3 years, 9 months ago by
Marc Tönsing.
-
This reply was modified 3 years, 9 months ago by
Marc Tönsing.
Hi Marc,
Fantastic! I didn’t know that!
Thanks!
@marcdk
5 stars and done!
One more question:
How can I make the plugin do not generate ID for H1?
When you have the same title and heading(usually a h2), it jumps to the top. This is usually happens when you write a question-answer article, with the same question as both title and a H2 heading.
I don’t include h1 in my toc, so disble auto-ID for h1 would be a solution.
Thanks!
Having another H1 on the same url is bad practice. Prevent using H1 headings in your posts. But you can use a custom id on the posts’ heading. Just change that
Hi,
Sorry, maybe this is more clear. Say I have an article with these headings.
<h1>why drink coffee</h1>
<h2>what is coffee</h2>
<h2>why drink coffee</h2>
<h2>coffee benefits</h2>
</ul>
In this case, even though I only generate TOC on H2s and I get
<ul class="simpletoc-list">
<li><a href="#123">what is coffee</a></li>
<li><a href="#123">why drink coffee</a></li>
<li><a href="#123">coffee benefits</a></li>
</ul>
The why drink coffee link will jump to the H1 instead of the H2 due to duplicated IDs.
I thought disabling generating H1 ID may be a permanent solution, is there any way to do that?
If not possible, I can manually assign an ID for the H1 as a workaround.
Thanks!
-
This reply was modified 3 years, 9 months ago by
tolddsm.
-
This reply was modified 3 years, 9 months ago by
tolddsm.
Why is every anker a “123”? This can’t work
Sorry I just copy paste your example, forgot to edit the anchor
<ul class="simpletoc-list">
<li><a href="#what-is-coffee">what is coffee</a></li>
<li><a href="#why-drink-coffee">why drink coffee</a></li>
<li><a href="#coffee-benefits">coffee benefits</a></li>
</ul>
Never mind, I’ll just edit the H1 ID to avoid duplicated anchors.