kunoichi / toc-generator
TOC generator from h1-h6 tags.
Installs: 5 363
Dependents: 1
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 1
Open Issues: 2
Requires
- php: >=7.0
- ext-dom: *
- masterminds/html5: ^2.7
Requires (Dev)
This package is auto-updated.
Last update: 2024-12-22 09:01:06 UTC
README
Generate table of contents from h1-h6 tags.
Installation
Run composer.
comopser require kunoichi/toc-generator
And include autoloader.
require __DIR__ . '/vendor/autoload.php';
Usage
PHP
W.I.P
WordPress
In your functions.php
// Register TOC. // If you have theme option for it, // detect conditions. add_action( 'init', function() { $parser = new Kunoichi\TocGenerator\WpParser(); $parser->set_title( __( 'Table of Contents', 'your-theme' ) ); } );
And render TOC where you want(e.g. In your singular.php
).
You need $post_id
to render TOC.
In this case, get_queried_object_id()
is used.
Kunoichi\TocGenerator\WpParser::render( get_queried_object_id() );