BACK TO DIRECTORY

Shortcode Table of Contents

by James Kemp

4.7
(6 ratings)

Simply use the [toc content=".your-container"] shortcode to automatically generate a table of contents for any HTML container.

The shortcode accepts a number of parameters:

  • content string required
    A CSS selector indicating the container of your content.
  • headers string
    A comma separated list of heading selectors that you want to include.
  • speed int
    Speed of sliding back to top.
  • anchor-class string
    Class of anchor links.
  • anchor-text string
    Prepended or appended to anchor headings. Leave blank to disable anchor links.
  • top_class string
    Back to top button or link class.
  • spy true/false
    Enable scroll spy. This will highlight the list items as you scroll past them.
  • position append/prepend
    Position of anchor text.
  • spy-offset int
    Specify heading offset for spy scrolling.

Screenshots

Add the [toc] shortcode to any post/page/custom-post-type, at any position in the content.

Add the [toc] shortcode to any post/page/custom-post-type, at any position in the content.

A nested list will be generated based on the headings within your chosen HTML element.

A nested list will be generated based on the headings within your chosen HTML element.

Add the anchor-text parameter.

Add the anchor-text parameter.

When the anchor-text parameter is set, the text will be appended to your headings so your users can easily copy the link to that section.

When the anchor-text parameter is set, the text will be appended to your headings so your users can easily copy the link to that section.

Plugin Details

Active Installs
200
Total Downloads
28,340
Version
1.0.3
Requires WP
4.0
Requires PHP
Tested Up To
4.9.31
Added
2017-11-29
Last Updated
2018-07-31 7:00pm GMT

Ratings

5
5
4
0
3
1
2
0
1
0