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]

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

[wpsm_stickypanel][contents h2][/wpsm_stickypanel]

If you want to change color of sticky panel on mobiles, here is the code


you can place this in theme options – general options – custom css

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 sticky Contents in sidebar, you can enable Rehub:Sticky on scroll widget and enable next option

You can also use shortcode in widgets

<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 (for pages and for posts) and Full Width Optimized (for posts).

But they are working a bit differently. Gutenberg AutoContents 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. Optimized Full width Post layout will count all headings in Content