WordPress Plugin: Table of Contents

Introduction

This WordPress plugin generates a table of contents based on header tags within the post and displays an indented list of anchor links at the top of each page or post containing any header tags.

Usage

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

A unique ID will be applied to each header tag not alreday containing an 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 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

Table of Contents closed

Example of a Table of Contents that is closed. This is the default state when loading the page.


Table of Contents open

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: 0
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:56
Requirements
Version:1.0.1Requires WordPress:5.0+Tested with WordPress:5.8.2Requires PHP:7.0+Created:October 19, 2021Last updated:October 19, 2021 4:14pm

4 tags for "WordPress Plugin: Table of Contents"


Leave a Reply

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