GitHub
Jim Valentine
@f13dev
f13dev
Margate, UK
f13.dev
Joined March 28, 2016
Margate, UK
f13.dev
Joined March 28, 2016
Coders Rank
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.
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 -->
Clicking on the Table of Contents header opens an indented list of internal anchor links for the current page.
Installation is as simple as 1,2,3 –