You can place the table yourself instead of, or as well as, inserting it automatically. When a post contains the AriTOC block or the [aritoc] shortcode, AriTOC does not add the automatic table to that post.
Add the block to a post or page
- Open the post in the block editor.
- Click where the table should go, add a block and search for Table of Contents (AriTOC).
- The block shows a preview of the post's headings. Change its options in the block settings: Content holds the title, heading levels, skipped headings and minimum headings; Look and behavior holds the theme, numbering, nesting and collapsing. Site default uses the value from Settings→AriTOC.
- Save the post.
If the post has fewer headings than the minimum, the block preview says “Hidden on the site until the post has at least this many headings:” followed by the number, and visitors see no table.
Add the table to a block theme template or sidebar
- Go to Appearance→Editor and open the template you want, for example the one for single posts.
- Add the Table of Contents (AriTOC) block where the table should appear, for example in a sidebar column.
- Save the template.
In a template, the block shows the headings of the post or page being viewed. Use it in templates for single posts and pages.
Add the shortcode
- Add a Shortcode block, or type into the text in the classic editor or a page builder text element.
- Enter
[aritoc]. Add attributes to override the site settings for this table, for example:
[aritoc title="In this article" levels="2,3" exclude="FAQ|Related*" numbering="roman" theme="dark" collapsible="yes" collapsed="no" hierarchical="yes" class="my-toc"]
Anything you leave out uses the settings page. Every attribute is listed in the shortcode, block and hooks reference.
Add the widget to a classic theme sidebar
- Go to Appearance→Widgets.
- Add the AriTOC: Table of contents widget to a sidebar.
- Optionally enter a Title: and tick Let visitors collapse it.
- Save.
The widget shows the table of the post or page being viewed, only on single posts and pages. It always shows its title, uses the full width of the sidebar and starts open.
Add it in a theme file
- Open the theme template where the table should appear, such as
single.phpin a child theme. - Add the template tag:
<?php if ( function_exists( 'aritoc' ) ) { aritoc(); } ?>
Pass the same options as the shortcode in an array, for example aritoc( array( 'levels' => '2,3' ) ).
Still stuck?
Our helpdesk answers on working days, Norwegian time. Include your WordPress version, PHP version, AriTOC version and the page address.