| 开发者 | MarcDK |
|---|---|
| 更新时间 | 2026年8月22日 16:52 |
| 捐献地址: | 去捐款 |
| PHP版本: | 7.3 及以上 |
| WordPress版本: | 7.1 |
| 版权: | GPLv2 or later |
| 版权网址: | 版权信息 |
"It is lightweight, stable, and fully compatible with WordPress Full Site Editing. A reliable solution that integrates seamlessly and performs exactly as expected." — @js100 on wordpress.org "Does the job perfectly, and adds no bloat." — @clicknathan on wordpress.org "Simple yet powerful. Great plugin that does exactly what you need." — @mixey on wordpress.orgAccessibility This plugin is designed & developed for WCAG 2.2 level AA conformance. The plugin is tested with assistive technology and intended to be accessible, however some third party plugins or themes may affect the individual accessibility on a given website. If you find an accessibility issue, please let us know and we'll try to address it promptly. Hidden TOCs use native
<details> and <summary> semantics without extra ARIA references that require custom IDs.
Features
SimpleTOC allows you to configure global settings for your WordPress website. These settings can be enforced globally, overriding any block-level configurations that may exist. To access these settings, navigate to the SimpleTOC section of the WordPress Settings.
Select the SimpleTOC block and open Gutenberg's Styles tab. Choose the Box style or use the native color controls to set text, link, and background colors. Native spacing controls are available for vertical margins and padding.
If you really want to hide a single heading from the table of contents, then add the CSS class "simpletoc-hidden" to a heading block. You can find this field in the same place as the HTML anchor field: In the Block > Advanced sidebar. But first, think about the reason you would like to hide a specific heading. Maybe you would like to remove all headings of a specific depth level. Then there is an option for that in the blocks options in Gutenberg. If you think this heading should not be part of the toc perhaps it is not needed in the post itself?
You can convert your configured SimpleTOC block into a reusable block in Gutenberg. It will keep its settings. This way, you can use your desired settings for each new post by adding the reusable block.
Add styles for the simpletoc/toc block to your theme.json. SimpleTOC uses the standard Gutenberg block wrapper and supports native colors, vertical margins, padding, font size, and line height settings.
The following example sets default colors, spacing, and typography for every SimpleTOC block:
{
"$schema": "https://schemas.wp.org/trunk/theme.json",
"version": 3,
"styles": {
"blocks": {
"simpletoc/toc": {
"color": {
"background": "#f5f5f5",
"text": "#1e1e1e"
},
"elements": {
"link": {
"color": {
"text": "#0057b8"
}
}
},
"spacing": {
"margin": {
"top": "1.5rem",
"bottom": "1.5rem"
},
"padding": {
"top": "1rem",
"right": "1rem",
"bottom": "1rem",
"left": "1rem"
}
},
"typography": {
"fontSize": "1rem",
"lineHeight": "1.6"
}
}
}
}
}
Replace the example values with your theme's values or preset variables. Selecting the Box style adds the standard is-style-boxed class.
Use the 'simpletoc_excluded_blocks' filter. For example, this code will exclude heading blocks that are inside a column block. Example: add_filter( 'simpletoc_excluded_blocks', function ( array $blocks ) { $blocks[] = 'core/column'; return $blocks; } );
The heavy plus character I used can not be colored with css without hacks. But you can change the icon to something else and change the color of the new icon. .simpletoc-collapsible::after { content: "✖"; color: #e94c89; }
I don’t see an easy solution at the moment. SimpleTOC is only a block that can be placed in your post. If there was a plugin that adds blocks to every post, then this would be the solution. I think this should be another separate plug-in to keep the code of SimpleTOC clean and … well, simple.