Introduction

Add a Table of Contents to any page or post automatically from Header tags. Any page that contains one or more heading tag (H1 – H6) will display a multi-level indented list of anchor links at the top of the page.

Usage

Table of Contents does not require any configuration. On page or post loading, the content is examined for header tags that be used to generate a ToC.

A unique ID will be applied to each header tag that does not already contain a valid ID.

<h1>Header 1</h1>
<h2>Header 2</h2>
<h2>Header 2</h2>
<h1>Header 1</h1>
<h2>Header 2</h2>

will be replaced with

<h1 id="f13-toc-1">Header 1</h1>
<h2 id="f13-toc-1-1">Header 2</h2>
<h2 id="f13-toc-1-2">Header 2</h2>
<h1 id="f13-toc-2">Header 1</h1>
<h2 id="f13-toc-2-1">Header 2</h2>

Each header tag with an existing ID will not be altered, instead the existing ID will be used for creating internal anchor links. For example, the headers on this page have pre-defined ID’s.

<h2 id="introduction">Introduction</h2>
<h2 id="usage">Usage</h2>
<h2 id="screenshots">Screenshots</h2>
<h2 id="installation">Installing</h2>
<h3 id="installation-wordpress">Via WordPress</h3>
<h3 id="installation-manual">Manual</h3>
<h2 id="github">GitHub</h2>
<h2 id="github">WordPress</h2>

If you do not want the Table of Contents to display on a certain page or post, add the following code at the top of the page or post (please note – copy this code exactly):

<!-- no-f13-toc -->

Screenshots

TOC closed
Example of a Table of Contents that is closed. This is the default state when loading the page.
TOC opem
Clicking on the Table of Contents header opens an indented list of internal anchor links for the current page.

Installing

Installation is as simple as 1,2,3 –

Via WordPress

  1. Navigate to WP Admin > Plugins > Add New
  2. Search for “F13 Table of Contents”
  3. Install and activate

Manual

  1. Download the source code
  2. Upload the “f13-toc” folder to your “wp-content/plugins” folder
  3. Activate the plugin in WP Admin

GitHub

GitHub repository: f13dev/f13-toc
Created: October 15, 2021 - 08:53pm
Last commit: October 19, 2021 - 04:31pm
Forks: 1
Open issues: 0
Stars: 0
Watchers: 0
Description: N/A
git clone https://github.com/f13dev/f13-toc

WordPress

Rating: (0/5 from 0 rating)
Description:Generate a table of contents based on header tags within the post. Outputs an indented list of anchor links at the top of each page or post linking to the relevant header tag. Tabe of Contents does no...
Tags:
table of contentstoc
Downloads:540
Requirements
Version:1.0.1Requires WordPress:5.0+Tested with WordPress:5.8.10Requires PHP:7.0+Created:October 19, 2021Last updated:October 19, 2021 4:14pm

4 tags for "WordPress Plugin: Table of Contents"

No comments on WordPress Plugin: Table of Contents

Share your thoughts

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.