Did you ever want to add a Wikipedia like table of content box on some of your long articles? A table of content makes it easier for users to jump to the section they want to read. It also helps with SEO, as Google automatically adds a jump to section link when your site appears in search results. Although you can manually create a table of content by writing custom HTML, it can be difficult for many WordPress beginners. In this article, we will show you how to create a table of content in WordPress posts and pages without writing any HTML or CSS.
Video Version of the Tutorial
If you don’t want to watch the video, then continue reading.
First thing you need to do is install and activate the Table of Contents Plus plugin. Upon activation, you need to configure plugin settings. Simply click on Settings » TOC+ in your WordPress admin area.
In the Main Options tab, you can select where and when you want your table of contents to appear. The default position is ‘before the first heading’. This means that the table of contents will be displayed before the first heading tag in your post or page. You can change it to top, bottom, or after first heading.
The next option is to decide when you want the table of content to appear. By default, the plugin will display table of contents if a post or page has more than 4 heading tags. You can change that to a lower or higher number.
The plugin will display Table of Contents only on pages by default. However if you want to enable automatic generation of table of contents for your posts as well, then all you need to do is check the box next to Post under the option ‘Auto insert for the following content types’. Check out our guide on the difference between Posts and Pages in WordPress.
Table of Contents Plus comes with a few default skins. You can choose them under the Presentation option. There is also an option to create your own custom style for your table of content box.
Once you are satisfied with the settings, click the Save Options button to store your settings.
How Does It Work?
The plugin will automatically generate table of contents for an article if it matches the criteria in your settings. By default it will generate the TOC if a page or post has at least four heading tags. These heading tags could be
<h1>, <h2>, <h3>, <h4>, etc.
If you do not want the plugin to generate table of contents for an article, then you can simply add the following shortcode to disable the table of content.
Remember, if you feel that you’re consistently adding this shortcode in your posts, then it might be worth it to change the plugin settings and/or disable auto-insertion option. The reason why we suggest this is because using using shortcodes in too many posts can be problematic.
If you disable auto-insertion, then you can use the following shortcode to insert Table of Content in your post or page:
If you want you can also display the table of content box in your sidebar widget. Simply go to Appearance » Widgets to drag and drop TOC+ widget in a sidebar. You can check the box next to ‘Show the table of contents only in the sidebar’ to display table of contents only in the widget and not in the post or page.