The table of contents block allows you to quickly navigate to the headings within your post or page by automatically creating anchor links to those headings.
You can either add the TOC block after you’ve created your content, or you can add it at the beginning. Either way, the block will recognize your headings automatically.
To add the block, click one of the “+” signs in the editor, or search for it using the “/” function:
Once the block has been added, take some time to customize it to suit your needs:
When you’ve achieved your design goals for the TOC block, view it on the front end to ensure it’s working as expected.
Advanced Usage of the Table of Contents Block
The TOC block is designed to pull headings from the “current” post or page. It’s not designed to pull headings from outside content, for example, headings that are in your footer, sidebar, or headings added by a hooked element. Headings that are not part of the page or post content are not going to show in your TOC block. It’s purpose is to find the headings inside of a page or post.
You add the TOC block in a sidebar or in an element that is hooked into a page; however the TOC block will not create navigation for an element or sidebar. It’s always looking at the current page content and not any other outside source.
Setting: Search for Headings in Non-static post content?
Your post content by default, is static and saved in the database as HTML with the headings all part of the content. Some blocks are a little different in that they do not save HTML data but instead save attributes and then render the attributes data into HTML markup that can contain headings on the front end when the post or page is viewed. The setting for “Search for Headings in Non static post content?” attempts to capture that content after the render so it can pick up headings that are dynamically generated in your page or post content.
Setting: Search for Headings in Template?
In Kadence Pro you can use hooked elements to create pages or post templates. The “search for headings in template” attempts to find the current custom page or post template you’ve created using Kadence Pro Elements. If found, any headings in those templates are added to the TOC block. If you are not using a custom template form Kadence Pro Elements this setting will not do anything.