How to make a table of contents in WordPress posts and pages – If you have ever visited a site with long articles and there is a table of contents in the article at the beginning of the article, it will certainly be very easy for you to navigate when reading the article to the section you want to read.
Apart from making navigation easier, adding a table of contents to the article will also help improve SEO on your site, because Google automatically adds these links to search results.
In the previous article I also made tutorial create a table of contents in manual posting that is, by writing custom HTML in the article in text mode, but this tutorial will be difficult for many WordPress beginners who do not understand HTML code very well, this plugin can also list the contents of the sitemap list of pages and / or categories throughout your site.
In this article, I will show you how to create a table of contents in WordPress posts and pages without writing HTML or CSS, everything is generated automatically with the help of the Toc + plugin.
Creating a Table of Contents in WordPress Posts and Pages
The first thing you need to do is install and activate the Plugin Table Of Content Plus. After the plugin is activated, you need to configure the plugin settings. Just click on the menu Settings »TOC + in your WordPress admin.
On the tab menu Main Options, You can choose 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 appear before the first heading tag in a post or page. You can change it up, down, or after the first heading.
The next setting is for setting when you want the table of contents to appear. By default, the plugin will show a table of contents if the post or page has more than 4 heading tag. You can change a lower or higher number value for the number of heading tags.
The plugin will display the Table of Contents only on the page by default. However if you want to enable the automatic generator of table of contents of your posts as well then all you need to do is tick the box next to Posts under the ‘options’Auto insert for the following content types‘. See the article about What is the difference between Post and Page in WordPress.
The Table Of Content plugin comes with several default skins or looks. You can choose the view under the options Presetation. You can also create your own custom styles for the skin or Table of Contents view. When you have finished making settings, click the button Save Options to save your settings.
How Do Table Of Contents Work?
The table of contets plus plugin will automatically generate a table of contents for the article if it matches the criteria in the settings you have made. By default it will generate a TOC (List of Contents) if the page or post has at least four post tags. This Heading Tag can be h1 h2 h3 h4 etc.
If you don’t want the plugin to generate a table of contents from an article, then you can add the following shortcode to disable table of contents.
Remember, if you feel that you are consistently adding this shortcode in your posts then it may be worth changing the plugin settings and / or disabling the auto-insertion option. The reason why it’s better to disable this option is because using too many shortcodes on posts can be problematic.
If you disable auto-insertion, then you can use the following shortcode to insert a table of contents in a post or page:
If you want you can also display the Table of contents in your sidebar widget. Please enter Appearance »Widgets then drag and drop TOC + widget to the sidebar area. You can tick ‘Show the table of contents only in the sidebar‘to display the table of contents only in a widget and not displayed in posts or pages. Please see the real demo here.
Above is an easy way to create a table of contents in articles in posts or pages of your WordPress site and if you want to use the manual method that does not use a plugin, then you can create a table of contents as above with the target specific link method as in the article here → Creating Target Specific Links in WordPress Posts, please try and I hope this article is useful for you. 🙂