1. Home
  2. ReHub Theme
  3. How to …
  4. How to make auto contents and table of contents for post

How to make auto contents and table of contents for post

Theme has several inner Table of Content shortcodes. It automatically add contents based on some tag. For example, you can divide your long article by H2 heading, so for creating autocontents add such shortcode:

[contents h2]

if you need to show also subheadings, use

[contents h2 h3]

Satisfy results. If you want to show list as line, use:

[wpsm_inline_list][contents h2][/wpsm_inline_list]

If you want to add contents inside sticky panel, use shortcode:

[wpsm_stickypanel][contents h2][/wpsm_stickypanel]

if you want to show contents inside block, use

[wpsm_titlebox title="Contents" style="1"][contents h2 h3][/wpsm_titlebox]

If you want to use Contents in sidebar, you can place shortcode in Rehub:Sticky on scroll widget. Use next shortcode (it will have also bordered box)

<div class="border-lightgrey-double pb15 pl5 pr15 pt15 rehub-main-color-border whitebg">[rh_side_contents]</div>

If you want to show only special headings in rh_side_contents shortcode, use next syntaxis

[rh_side_contents headers="h2"]

this will use only h2 headings in shortcode

Theme has special pattern to add all shortcodes quickly in Gutenberg. Just search for Table of content when you add new block

Also, you can use more powerfull wpsm_toplist shortcode, see how to use it.

By the way. There are also Post Layout and Page layout which generate table of content automatically. These are Gutenberg Auto Contents post layout.

But they are working a bit differently. They will count only if you use Gutenberg Color Heading and Review Heading Blocks And only Subtitles will be counted in Table of Contents. This is made because usually, you may need to have short titles in Table of Contents but your main Headings can have long words for SEO purposes. So, you can use short strings in Subtitles to generate table of contents