Plugin hau ez da probatu WordPressen azken 3 bertsio garrantzitsuenekin. Baliteke, jada, mantentze edo euskarririk ez izatea, eta, WordPressen bertsio berriagoekin erabiltzen denean, bateragarritasun arazoak izan ditzake.

Shortcode Table of Contents

Deskripzioa

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.

Pantaila-argazkiak

  • 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.
  • 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.

Instalazioa

  1. Upload the plugin files to the /wp-content/plugins/shortcode-toc directory, or install the plugin through the WordPress plugins screen directly.
  2. Activate the plugin through the ‘Plugins’ screen in WordPress

MEG

Installation Instructions
  1. Upload the plugin files to the /wp-content/plugins/shortcode-toc directory, or install the plugin through the WordPress plugins screen directly.
  2. Activate the plugin through the ‘Plugins’ screen in WordPress
Can I use the shortcode multiple times on a page?

No. Currently it’ll only work once per page.

The table of contents isn’t showing up.

Did you set the content parameter of the shortcode to a valid CSS selector on your page? This is a required argument.

Can I build a table of contents for just h2 and h3 tags?

Yup, your shortcode would look like this [toc content=".your-container" headers="h2,h3"]

Is there a PHP version of the shortcode?

You can use the do_shortcode() function like this:

<?php echo do_shortcode( '[toc content=".your-container"]' ); ?>

Berrikuspenak

2019(e)ko otsailaren 26(a)
It does not work if the site is in Cyrillic.
2018(e)ko urriaren 28(a)
Great simple plugin! There are no filters available to set shortcode defaults. My clients dont know the right class names to set the parameter ‘content’. So if you want to set the default class for ‘content’ or set the default set of headers, use filter ‘shortcode_atts_{shortcode}’. This way you the shortcode get much cleaner like ‘[toc]’. If the parameters in the shortcode are set, the default are over ruled. Filter like: add_action('shortcode_atts_toc','nen_shortcode_atts_toc'); function nen_shortcode_atts_toc( $out ) { if( isset( $out['content'] ) && empty( $out['content'] ) ) $out['content'] = '.entry-content'; if( isset( $out['headers'] ) && $out['headers'] == 'h1, h2, h3, h4, h5, h6' ) $out['headers'] = 'h2, h3, h4'; return $out; } Hopefully James Kemp can apply a filter to add custom content before and/or after the div ‘shortcode-toc’. This way we can add a custom toc-header or something. Thanx!
2018(e)ko ekainaren 2(a)
I needed to make navigation for posts, and this is a ready-made automated solution. Many thanks.
2017(e)ko abenduaren 28(a) 1 reply
Very lightweight and at the same time versatile enough with useful options.
Irakurri 6 berrikuspenak

Laguntzaileak eta Garatzaileak

“Shortcode Table of Contents” software librea da. Ondoko pertsonek egin dizkiote ekarpenak plugin honi.

Laguntzaileak

Aldaketen loga

v1.0.3 (31/07/2018)
[fix] Revert back to original anchorific. Bower one was an old version.

v1.0.2 (01/12/2017)
[update] Use latest anchorific.

v1.0.1 (30/11/2017)
[update] Remove anchor text by default.
[fix] Ensure ‘spy’ param works with true/false values.

v1.0.0 (29/11/2017)
[release] Initial release.