Table of Contents Plus

A powerful yet user friendly plugin that automatically creates a context specific index or table of contents (TOC) for long pages (and custom post types). More than just a table of contents plugin, this plugin can also output a sitemap listing pages and/or categories across your entire site.



Built from the ground up and with Wikipedia in mind, the table of contents by default appears before the first heading on a page. This allows the author to insert lead-in content that may summarise or introduce the rest of the page. It also uses a unique numbering scheme that doesn’t get lost through CSS differences across themes.

This plugin is a great companion for content rich sites such as content management system oriented configurations. That said, bloggers also have the same benefits when writing long structured articles. Discover how Google uses this index to provide ‘Jump To’ links to your content.

Includes an administration options panel where you can customise settings like display position, define the minimum number of headings before an index is displayed, other appearance, and more. For power users, expand the advanced options to further tweak its behaviour – eg: exclude undesired heading levels like h5 and h6 from being included; disable the output of the included CSS file; adjust the top offset and more. Using shortcodes, you can override default behaviour such as special exclusions on a specific page or even to hide the table of contents altogether.

Prefer to include the index in the sidebar? Go to Appearance > Widgets and drag the TOC+ to your desired sidebar and position.

Custom post types are supported, however, auto insertion works only when the_content() has been used by the custom post type. Each post type will appear in the options panel, so enable the ones you want.


Install / upgrade

Install the plugin by searching for Table of Contents Plus from the plugin add menu, or directly from the WordPress plugins repository.

There are no special upgrade instructions (woohoo!). Overwrite your existing folder with the latest or use the streamlined approach in the plugin menu. Your options will not be lost.


The simplest approach

For the impatient, all you have to do is enable the plugin.

The plugin will apply default settings and produce the table of contents before the first heading on pages (not posts, nor custom post types) with four or more headings.

No shortcodes are needed.

Where’s my table of contents?

  1. In most cases, the post, page or custom post type has less than the minimum number of headings. By default, this is set to four so make sure you have at least four headings within your content. If you want to change this value, you can find it under ‘Main Options’ > ‘Show when’.
  2. Is auto insertion enabled for your content type? By default, only pages are enabled.
  3. Have you got [ no_toc ] somewhere within the content? This will disable the index for the current post, page or custom post type.
  4. If you are using the TOC+ widget, check if you have the “Show the table of contents only in the sidebar” enabled as this will limit its display to only the sidebar. You can check by going into Appearance > Widgets.
  5. You may have restricted generation to a URL path match. The setting can be found in the advanced section under Main Options.

How do I stop the table of contents from appearing on a single page?

Place the following [ no_toc ] anywhere on the page to suppress the table of contents. This is known as a shortcode and works for posts, pages and custom post types that make use of the_content()

I’ve set wrapping to left or right but the headings don’t wrap around the table of contents

This normally occurs when there is a CSS clear directive in or around the heading originating from the theme (Twenty Eleven and Twenty Twelve are two themes which do this). This directive tells the user agent to reset the previous wrapping specifications.

You can adjust your theme’s CSS or try moving the table of contents position to the top of the page. If you didn’t build your theme, I’d highly suggest you try the Custom CSS plugin if you wish to make CSS changes.

Try adding the following CSS to allow the wrapping to occur around the table of contents:
h1, h2, h3, h4, h5, h6 { clear: none; }

How do I include the name of the page in the table of contents title?

As the title of the page changes depending on the page you’re viewing, you can use the following special variable to automatically insert the title of the page into the table of contents heading:


You can use it as is or place text either side of the variable.

As an example: if your page is named Great Expectations and your table of contents title is set to Contents for %PAGE_NAME%, the final title would read Contents for Great Expectations

My site has 100 pages but I only want the table of contents to appear on 10 of them

You could put [ no_toc ] on the 90 pages but that wouldn’t be fun… so try the following:

  1. Go to Settings > TOC+ and disable the auto insertion option for pages (or the content type you’re working with).
  2. Add [ toc ] onto the 10 pages that need them. Note that the table of contents will appear where you placed the shortcode.

Alternatively, you could also experiment with the restrict path option if the pages you want to include the index on all fall within a certain section of your site (eg /doc/).

I want to ignore certain headings

Use the ‘exclude headings’ option if you would like to ignore certain headings. Separate multiple headings with a pipe |. Use an asterisk * as a wildcard to match other text. Note that this is not case sensitive. Some examples include:

  • Fruit* ignore headings starting with Fruit
  • *Fruit Diet* ignore headings with Fruit Diet somewhere in the heading
  • Apple Tree|Oranges|Yellow Bananas ignore headings that are exactly Apple Tree, Oranges or Yellow Bananas

Can I have the table of contents in the sidebar?

Use the TOC+ widget and drag it into your desired position. If you want the table of contents to only be displayed in the sidebar, then make sure you tick that option in the widget.

Unlike Wikipedia, I want all my anchors to be lowercase and use hyphens rather than underscores

There are two options that allow you to adjust the casing and use of hyphens. If you still require more, you can massage it a little more by attaching into the toc_url_anchor_target filter. See the developers section for an example.

I would like to incorporate a sitemap

  1. Create a page for your sitemap (if you have an existing one, use that instead).
  2. Add [ sitemap ] into your page and save.

The above is the simplest example of integrating a sitemap listing all pages and categories. You can customise the sitemap options under Settings > TOC+ or check out some of the more advanced uses with the sitemap related shortcodes below.

You could also incorporate a sitemap using a text widget and pasting any of the sitemap shortcodes.

The sitemap uses a strange font dissimilar to the rest of the site

No extra styles are created for the sitemap, instead it inherits any styles you used when adding the shortcode. If you copy and pasted, you probably also copied the ‘code’ tags surrounding it so remove them if this is the case.

In most cases, try to have the shortcode on its own line with nothing before or after the square brackets.


The plugin was designed to be as seamless and painfree as possible and did not require you to insert a shortcode for operation. However, using the shortcode allows you to fully control the position of the table of contents within your page. The following shortcodes are available with this plugin.

When parameters are left out for the shortcodes below, they will fallback to the settings you defined under Settings > TOC+.

[ toc ]Lets you generate the table of contents at the preferred position. Also useful for sites that only require a TOC on a small handful of pages.
  • label: text, title of the table of contents
  • no_label: true/false, shows or hides the title
  • wrapping: text, either “left” or “right”
  • heading_levels: numbers, this lets you select the heading levels you want included in the table of contents. Separate multiple levels with a comma. Example: include headings 3, 4 and 5 but exclude the others with heading_levels="3,4,5"
  • exclude: text, enter headings to be excluded. Separate multiple headings with a pipe |. Use an asterisk * as a wildcard to match other text. You could also use regular expressions for more advanced matching.
  • class: text, enter CSS classes to be added to the container. Separate multiple classes with a space.
[ no_toc ]Allows you to disable the table of contents for the current post, page, or custom post type. 
[ sitemap ]Produces a listing of all pages and categories for your site. You can use this on any post, page or even in a text widget. 
[ sitemap_pages ]Lets you print out a listing of only pages.
  • heading: number between 1 and 6, defines which html heading to use
  • label: text, title of the list
  • no_label: true/false, shows or hides the list heading
  • exclude: IDs of the pages or categories you wish to exclude
  • exclude_tree: ID of the page or category you wish to exclude including its all descendants
[ sitemap_categories ]Similar to [ sitemap_pages ] but for categories. 
[ sitemap_posts ]This lets you print out an index of all published posts on your site. By default, posts are listed in alphabetical order grouped by their first letters. There are CSS classes for each section, letter and list allowing you to customise the appearance.
  • order: text, either ASC or DESC
  • orderby: text, popular options include “title”, “date”, “ID”, and “rand”. See WP_Query for a list.
  • separate: true/false (defaults to true), does not separate the lists by first letter when set to false.

For developers

How do I customise my anchors?

If you’re still not happy with the anchors, you can modify them to suit your needs through a custom function hooked into the toc_url_anchor_target filter. As an example, place the below code snippet into your functions.php file to convert all anchors to uppercase.

function my_custom_anchor( $anchor )
	return strtoupper( $anchor );
add_filter( 'toc_url_anchor_target', 'my_custom_anchor' );

toc_get_index( $content = ”, $prefix_url = ” )

Returns a HTML formatted string of the table of contents without the surrounding UL or OL tags to allow the theme editor to supply their own ID and/or classes to the outer list.

Both parameters are optional:

  • $content is the entire content with headings. If blank, will default to the current content found in $post (eg within “the loop”).
  • $prefix_url is the URL to prefix the anchor with. If a string was provided, it will be used as is. If set to “true” then will try to obtain the permalink from the $post object.

These examples assume you are within “the loop”:

  1. Obtain the index for the current page
    echo '<ul id="my_toc">' . toc_get_index() . '</ul>';
  2. Create a listing of all children and their headings
    $children = new WP_Query(array(
    	'post_parent' => get_the_ID(),
    	'posts_per_page' => -1	// get all children
    while ( $children->have_posts() ) {
    		'<h3>' . get_the_title() . '</h3>' .
    		'<ul>' . toc_get_index( get_the_content(), get_permalink( $children->post->ID ) ) . '</ul>'

Versioning scheme

I have adopted the same Ubuntu versioning scheme so the first release is 1107.

Other releases in the same month will be dot releases, eg the second release in July 2011 is 1107.1.

I love it, how can I show my appreciation?

If you have been impressed with this plugin and would like to somehow show some appreciation, rather than send a donation my way, please donate to your charity of choice. Feel free to leave a short note here if you’d like.

I will never ask for any form of reward or compensation. Helping others achieve their goals is satisfying enough πŸ™‚

Questions or suggestions?

If you have questions or suggestions, please place them below.

1,136 thoughts on “Table of Contents Plus

  1. Hello, Mike , I am using your plugins, thanks for so good plugins.
    I am having a question, I am writing an long aritcle with a number of sections, What should I do if I want to return the index after reading every sections? I mean inserting a link to return the index or something , any idea?

    • Mike T says:

      I would recommend using a ‘back to top’ plugin to do this for you. A good one is Dynamic To Top.

  2. Jonathan says:

    How do I set the TOC to default to “hide” when the page loads. PLEASE NOTE: I’m not saying I don’t want the TOC on the page. I’m saying I don’t want the TOC box OPEN. I would prefer that my pages look nice and clean yet give users the OPTION to OPEN the TOC box if they choose to do so.

    How is this achieved?

    Thanks for the great plugin! πŸ™‚

    • Mike T says:

      Someone asked about this earlier but there wasn’t an easy one or two line change to do this. It would require inverting most of the conditional logic that deals with the show/hide.

      Also, having it open by default has its benefits: allows your user to skim the structure of your documents, it may be needed for Google’s jump to links in searches.

      Alternatively, with some CSS and JS, you could style and position the TOC out of prime real estate, eg placing it consistently down the left as you scroll (check out a Verge article). Before you ask, no this isn’t a standard option in the plugin because it heavily relies on each theme.

  3. Gabe says:

    This plugin looks amazing, but I see there have been no updates since December. Are you still actively supporting?

    • Mike T says:

      Of course! Have a couple adjustments already put in but I want to sort out the toc on paged content (eg nextpage). Also a major project has been consuming my time the past few months but that is nearing completion.

      • Gabe says:

        Sorry, my bad- I was going through the comments and missed the ‘newer comments’ link, so I thought they stopped in October. That’s why I thought nothing was going on since the last update.

        Thanks, and keep up the great work!

  4. By far, this is my favorite WordPress plugin out there. I’m still setting up my page to incorporate your plugin but it’s exactly what I need since I plan to display an entire book on my site as the chapters come together. Just wanted to say thanks for developing this. It’s perfect.

  5. Really nice plug in – got it working first time with a single level TOC based on headings (H3’s). Then I added some H4’s but only the first of 5 displayed? Any ideas? You can see the page here

    So then I tried using the manual [TOC] to see if I could create a main TOC at the top of the page, just with h3’s in, and then a second single level TOC in the letters section with h4’s. I’m probably being daft, but can’t get either to pick up on heading_levels=”3″ parameter – can you show us exactly what the syntax is – e.g. [TOC heading_levels=”3″] as I’ve tried a couple of permutations without success. Many thanks.

  6. Hiya !

    Ahhhh this is it !

    Happy i am πŸ™‚

    well now, how to translate it ? There is no default pot file in it should i just generate it with poedit from sources ?

    thanks πŸ™‚

    • Mike T says:

      Thanks for the gesture. I’m not sure what you do to translate so I’d take your guidance on that πŸ™‚ Where possible, I’ve tried to make it translatable within the code except for the lengthy help part. Might convert the help at some point.

      • Ok will have a test. Well, translate the whole settings part for end users, since i intend to use that on multisite. Will test that, translate, and send you the pot/po files πŸ™‚

  7. maxbux says:

    Hi Mike,
    Awesome plugin, can’t wait to put it into production.

    I have noticed that if a post is paginated, (), the plugin disregards headers in the next page.

    Is there a way to get around this? I mean can’t the plugin also fetch headers past the pagination and display then on the first page?

    Thank you

  8. Simone says:

    thanks for this plugin. Is possible to add in header js and css only in the post where I use TOC? I use it only for one taxonomy. I have tried to use the function “Auto insert for the following content types” with the only one taxonomy that I need, but i see the extra css and js in all the pages of my website.

    • Mike T says:

      Nice suggestion. Will look at it for the next release.

      The good news is that your browser should be serving from cache rather than pulling from the server on all requests.

      The javascript file may need to be left in the header as it would be required for the smooth scroll effect for anchor links. It’s a desirable feature that works not only for TOC links.

  9. Marc says:

    I like this plugin. BUT when it creates a table of contents on a page, it puts it in a container that doesn’t use the full width of the area it is being displayed in, so the items in the list wrap round prematurely. [Sorry, I am a novice at all this, so β€˜area’ is probably not the correct term]. Using Firebug, it seems that the width of the table of contents is determined by the following code:

    div#toc_container {
    font-size: 100%;
    width: 75%;

    And the width is determined by the 75% parameter.
    My problem/question is: where does this value of 75% come from? It looks as though it has been inherited from somewhere, but I don’t know my way around CSS files to understand where from. Which specific CSS file sets up this 75% value, assuming it does come from a CSS file? Help appreciated! I’m sure it’s obvious to a pro, but it’s a mystery to me.

    • Mike T says:

      The container width is controlled in your administration interface under Settings > TOC+, with the width drop down list. The default width is 275px so you would have already played with the options before to change it to 75%. There is a 100% option if you want, or if you want it to behave truly like Wikipedia (eg auto width to the text within), change it to auto.

      No CSS hacking needed πŸ™‚

      • Marc says:

        Hey Mike, thanks for the prompt reply. It’s too late at night to do this now, but I’ll do it tomorrow.

        Don’t like hacking CSS, so this is good news.

        Thanks again!!


  10. Gabe says:

    Hmmm, sorry for the link situation there. I guess I didn’t pay close attention to the comment when I left it. Sorry about that.

  11. Gabe says:

    Hi there,

    I’m using your plugin on a 3.3.1 WP install and I’m seeing some strange behavior.

    Whenever I click on any of the links created by the plugin on a post, they always take me back to homepage and not to the appropriate location in the document.

    So in other words, the anchor kind of looks like…

    instead of looking like…

    For some reason, it’s not appending the anchor to the post itself but rather reedirecting everything to the homepage. This happens on all posts. I’ve got the plugin disabled for pages.

    Any ideas on where I can start troubleshooting this kind of issue?

    Oh also, the “show/hide” functionality is not working.

    Thanks for the cool plugin!

    • Mike T says:

      You’re probably using a Google Analytics/SEO plugin which makes all relative links absolute from the domain. The TOC plugin only prints out the anchor.

      Check out this for background and an easy fix.

      • Gabe says:

        Hi there,

        I had a go at your suggestion and edited the toc.php but to no avail. I’m not using the plugin that was mentioned for Google Analytics by the way.

        I am using Yoast’s Robots Meta plugin but I couldn’t find anything in there about URL stripping.

        The only other plugin I’m using that impacts URL formats is WP No Category Base
        which removes the WORD ‘/category’ from the category permalinks.

        My permalinks settings are as follows…


        Otherwise, in my code, the URL(that should precede the anchor) is totally missing…

        It’s just as opposed to

        There’s nothing in the HREF related to that particular URL/post at all, just an anchor to nowhere.

        Hope that clarifies things some and doesn’t muddy the water unneccesarily.


        Any ideas?


      • Mike T says:

        The thing is this plugin doesn’t add anything before the anchor link so something else is getting in and doing it. The solution that worked with GA for WordPress by Yoast was to make this plugin run later in the chain. Can you try increasing the number from 100 higher? Say 1000?

        add_filter( 'the_content', array(&$this, 'the_content'), 1000 );

        Do you have a link you can send me? You can send to michael at this domain.

        I think it’s going to be a bit of plugin isolation – eg start disabling plugins to see which is causing it. If you can start with all disabled that would be great.

  12. To give you an idea of what i’m talking about, here is my article using a single post which i split into sub pages using the next-page code for wordpress.

    Your plugin is enabled, but it doesn’t show a TOC. because apparently it only shows a toc if 4 headers or more are shown in the current displayed page. Which in my case it can’t because the content of the post has been split into multiple sub pages, and your plugin cannot detect the headers for them even though their all under the same single post :{

  13. Hi,

    Firstly awesome plugin. Unfortunately i noticed, it cannot create table of contents for headers located on a different sub page when using the NEXT-PAGE separator in a single Post.

    Would you be able to add this feature into this plugin ?

    I split up my content using next-page so 1 single page isn’t bogged down with too much detail. But i still want to add a TOC so people can also easily navigate these split pages.

    Something like this but using your plugin

  14. Hey Mike,

    I’ve been using this great plugin. It is really clean, nice and works fine with latest wordpress 3.3.1. I would like to know if there is a way to make TOC floating? So if we scroll down, the TOC will follow the page movement. Wonder if you can make any update about it.

    Best wishes,
    Ahmad Akmal πŸ™‚

  15. I’m currently working on a website for my workplace, and am using TOC+ version 1112.1.

    I’m having a problem where, if I have two pages with TOC+ on them in the same category, the TOC on Page1 will link to the TOC on Page2. This happens even if the headings are different.

    For example, this page’s TOC:

    takes you to this page:

    I’ve tried disabling all plug-ins except TOC+, and I still have the same problem. Not sure what else to do at this point. It’s become very frustrating. Any idea why this might be happening?

    • Mike T says:

      I’ve had a quick look and yes it is strange and definitely not intended. I noticed that the toc links are absolute (eg, href=http://domain/dir/page#anchor) when they should only be the anchors (href=#anchor). I will need to look more closely at it.

    • Mike T says:

      Did a bit more investigating and something is definitely changing the hyperlinks to make it absolute and it’s not the plugin. It’s happening on my site here (which is a basic shared host) but none of the others where I have full control over the server.

      The two dead giveaways are summarised as link munging

      1) The hyperlink includes everything to the left of the anchor including protocol, domain, directory, and page. It should only be the anchor.

      2) There is an extra space before the closing hyperlink code where there shouldn’t be.

      I know my simple host has mod_security, suhosin and some Zend products. Who knows what else they may have in terms of server hardening. I would suggest that you check for any of these and if you do, please let me know! I will try to get another server installed with the extra tools to identify the culprit.

      Btw, I doubt it be suhosin related as I have that enabled everywhere.

      • Hi, Mike!

        Thanks for your response. I did some more testing, and I figured out that the culprit was the Google Analytics for WordPress plugin. I must have missed that one when I was testing plugins the first time around. I disabled that, and everything is working fine. Sorry for the extra work I put you through!

      • Mike T says:

        Thanks for following up. I use that same plugin on this site which now explains it. I’ll do some investigating and see if I can get it to work in tandem.

      • Mike T says:

        Yep it was the Google Analytics for WordPress plugin as there is a function specifically to convert relative links (including anchors) into full absolute links called yoast_sanitize_relative_links in the googleanalytics.php file.

        There is a simple solution though, if you edit line 129 of toc.php (version 1112.1) and change the number from 11 to 100, that should do it. This tells it to attach the table of contents after the other plugin does its thing. The line should look something like:

        add_filter( 'the_content', array(&$this, 'the_content'), 100 );

        Let me know how you go!

  16. Edwin says:

    Hi Mike,
    I’ve got some questions. May I know:
    1) Why some of the headings are not appering on the toc? You can take a look at my site , at the home page itself. Not showing any headings after side effects.

    2) There is a number at the toc but no headings, please look at – toc no.5

    3) Is it possible for us to customize the contents in the toc? For example if the heading is too long, can we replace it with a shorter one?

    Your advise on the ways to solve all the above-mentioned problems shall be greatly appreciated. Thanks.

    • Mike T says:

      1. Check out this which appears to be the same problem. Basically, you need the text of the heading to be on the same line so switch over to HTML mode and double check.

      2. You have a heading 2 with a space in your content. Remove it and it’ll disappear from the TOC.

      3. Nope, the TOC is automatically generated from your content. You will need to shorten it in your content.

  17. I have the table of contents working fine using [toc] but unsure how to modify it. If I want only header levels 3,4,5 to show up in the TOC, where do I put “heading_levels=”3,4,5” in relation to [toc] and what tags do I use, if any? I’ve never tried to modify a shortcode before, don’t know the syntax for it. Thanks!

    • Mike T says:

      If you’re already using the [toc] shortcode, then you’d want to change that to look like

      [toc heading_levels="3,4,5"]

      That will only grab headings 3, 4 and 5 for that content item you’ve put it on. Alternatively, if you want headings 3, 4 and 5 globally, you can do so under the advanced options in Settings > TOC+.

  18. Johana says:

    Hello, thank you for this nice plugin! πŸ™‚

    I would like to know if it’s possible to have 1.XXXX, 1.1XXXX, 1.2XXXX not only in the TOC but in the differents post titles?

    If it’s not possible, have you planned to add this option?

    • Mike T says:

      Nope, it doesn’t prepend those numbers to the actual headings within the content. It only does so in the table of contents if you have that option enabled.

      I haven’t planned for it and you’re the first to ask. If more request it then it’ll get some better focus πŸ™‚

  19. Jonas says:

    Awesome plugin! I’m using pagination with , is there a way to include all the headings in the other pages? It seems the only headings displayed are the ones in the current page.

    Also, what is the default visibility when the user first visits the page? Can we make it to default to ‘hidden’ always?

    Thanks for your great work.

    • Mike T says:

      I think what you have described when pagination is used is what is expected as this plugin uses the_content filter to grab its content for the page. Pagination is a WordPress core feature so I imagine it would be stripping out paged content before feeding into the_content and don’t expect it to have the complete content in its entirety. I can see where a holistic TOC for the one page (with pagination) can be useful though. So to answer your question, no there is no current way… yet.

      There isn’t an option to change the TOC visibility option to hidden. The TOC, by default, is displayed to all users but gives the individual the option to hide for whatever reason. This is on a per site level which means that they hide it once, and it hides all TOCs for your site.

      If you’re still keen on changing the default, then edit front.js and on line 68 of version 1112.1, change:

      …code being revised

      …hmm it’s not going to be a simple 1 line change. It will need an inverse of most of that part of the file.

      • Jonas says:

        I changed ‘visibility’ => true, in the $defaults array to false, I thought it worked but it turns out Chrome just remembers the previous setting.

        Thank you for the plugin Mike. I hope you can incorporate these two in the future πŸ™‚

  20. Hi, your plugin is very usefull, I use it in a few places of my website with the shortcode.. Though I would like to reduce the margin on top and bottom and it at 0 in the CSS and I don’t know where else I coud reduce it. Thank you very much!

    • Mike T says:

      As far as I can see, there is only a bottom margin of 1em specified for the div surrounding the table of contents. It will inherit everything else from the theme.

      So if you want to add or remove paddings or margins, start with #toc_container as your CSS selector and go from there.

  21. Natha says:

    I have been using your plugin for a long time but since updating it takes down my entire site. The last version that worked for me was 1108.2

    Was there something that changed after that version? If theres anything I can do on my side to troubleshoot for you please let me know.

    • Mike T says:

      I’m sorry to hear that. I’ve had another report over at the wordpress forums of similar experiences too. If you could send me the relevant parts of your webserver logs for when it breaks that would be very handy. I’ll probably also need an idea of the hosting platform you’re on eg Linux/windows, apache/nginx/iis, version of php, etc. You can send directly to me by email at michael at this domain.

  22. Great plugin ! Thanks :o)
    In main settings, 2d line : “Show when x or more headings are present”, the smallest number available is 3. Why ?
    I think it’d be great if 2 was possible. It’d be useful when the contents under the headings are long.
    For instance, I’m making a site for friends, with an “about us” page. Two persons are to be introduced in there but each their introduction is quite long. Without a table of contents, the reader might think only one person will introduce herself. So at this point, I’ll make the TC manually, which is a little stupid when such a great plugin as yours is installed ;o)


    • Mike T says:

      Sounds good. To do it now, edit toc.php and change

      define( 'TOC_MIN_START', 3 );


      define( 'TOC_MIN_START', 2 );

      This is near the top (line 46 for version 1112.1). You can now go to Settings > TOC+ and select 2 from the drop down list.

  23. Pingback: Table of Contents Plus 1112.1 released | dublue

  24. Pingback: Table of Contents Plus 1112 released | dublue

      • seopoet says:

        Yes, that was it. It seems that there were no such problem in previous versions of your plugin. Sorry for multiposting.

      • Mike T says:

        I copied your content and added it into my dev environment but still haven’t got it to add “-2” to my anchors yet. I’ve got content from Alan and one other and haven’t been successful replicating theirs either. I’ll keep debugging.

        Yep, prior versions automatically incremented the index with a number to avoid repeated headings. The numbers made no sense.

        The 1111 version removed the autoincrements and added better detection of repeated headings. The numbers are added to repeated headings and identify which repeat it was. The benefit is now you get links that are meaningful while avoiding repetitions.

    • Mike T says:

      Good news everybody – I’ve got this problem sorted.

      Long story short, some themes and plugins initiate the_content one or more times which was setting off TOC+.

      Expect an update in the coming days.

  25. seopoet says:

    Hi Mike,

    On my website TOC+ has generated different span ids for the headings like this:

    code in TOC:

    `Fat-reduced Bacon`

    code in the heading the above should link to:

    `Fat-reduced Bacon`

    Never seen that before. All of the old posts are fine. Any ideas?

    Thanks for your great plugin.

  26. seopoet says:

    Hi Mike,

    On my website TOC+ has generated different span ids for the headings like this:

    code in TOC:


    but in the post body the adequate headings are marked as:

    [code]Processed Meat Products[/code]

    Never seen that before. All of the old posts are fine. Any ideas?

    Thanks for your great plugin.

  27. ungovernable says:

    Hello, i have a problem and i’m willing to send a paypal donation if you can help me to fix it

    i’m using this mod to display the summary on the front page of my blog. But as soon as i use the “read more” tag the summary will be displayed only inside the article… I tryed a similar mod and i had the same problem..

    I want the summary to be always displayed on the index.php page, even when the “read more” tag is used…. Is it possible to fix that ?


    • Mike T says:

      Thanks for the link. One other person has sent through what appears to be the same problem and I haven’t yet worked out what is causing it. The sample I have are the simplest of tests.

      Essentially it’s adding “-2” to the end of the anchor but the links don’t have them which is why they aren’t going anywhere. It only does this when it thinks there might be a collision so it’s obviously running twice but I gotta figure out why and under which situations as it isn’t occurring all the time.

      This bug is high on my list and will be squashed with the next release or there won’t be a Christmas!

      • Thanks for working on it Mike. My theme is from I don’t know if that helps or if you need to see some of the code. It’s the Vidley theme.

  28. Ernst says:

    Thanks for the nice plugin. But I have one bug/feature request. I want to show up the toc only in the sidebar. So I added the widget into the sidebar and checked the option “Show the table of contents only in the sidebar”. This works. But what doesn’t work are attributes passed to [toc]. If you, e.g., specify the following: [toc label="Employees"] no toc is displayed when activated the above widget option. Can this be fixed? Or better asked: is this a bug or a feature?

    • Mike T says:

      The behavior you described is expected. The widget operate independently from manual toc options you provide in the content of posts, pages, or other content types.

      The widget is currently in it’s infant stage as I need more ideas around how it will be used by the majority of users. Eg scenarios/use cases. But the example you provided could be achieved by editing the title for your widget.

      • Ernst says:

        Hi Mike,
        thanks for the response. Yes this scenario can be provided by setting the name of the widget. But it was just an example by myself πŸ˜‰ So actually, I really want to define the heading_levels for the widget for each page independently. Therefore it would be nice to being able to set the label for each page independently, too.

      • Mike T says:

        Ahh yes I can see the benefits of supplying different widget properties on a per instance basis.

        Generally speaking, widgets have tended to operate independent from content. It gets trickier as supplied properties intended for shortcodes arn’t carried across to widgets as they do not execute within the same context. The only elegant way (that I can think of right now) is to use custom fields to store the properties. If this is the case, it could be done via a wysiwyg button to promote usability but I hate the idea of adding extra buttons that are rarely used cluttering up the real estate. More thought is definitely needed.

  29. Firstly, thanks for creating this plugin!
    I am using a manual TOC my posts and I just switched all the posts to excerpts. The home page ( now shows an empty TOC and I am wondering if this can be turned off.

    I read earlier posts about this issue and that a new option resolved it so I checked the Show the table of contents for qualifying items on the homepage option and made sure that it is off.

    Any insight would be appreciated.


    Ulrich Palha

    • Mike T says:

      Thanks for providing the link. I will take a look but I don’t think they’re related. It looks like a bug in the logic which I push out asap after addressing it.

  30. Phil says:

    Nice work on the latest update. I just tried the sitemap feature for the first time. Is it not possible to have the post themselves listed out also?

    All I see is a category/page tree.

  31. Peter says:

    I sent a query through earlier today about a situation where the TOC+ plugin was giving different results in 2 cases on the same website. I decided to test the text of the rogue post by copying it into Frontpage and found 2 lines with extra spacing between the lines. I sorted out the spacing and hey presto TOC+ is now working on the website. Strange, but now I know to check text formatting very carefully. Great plugin, sorry for the red herring.

  32. I am using your plugin and love it. But I have a strange thing happening. For one of the TOC posts the Table of Contents appears but is empty, for others it works fine. Also if I include widget TOC the working post displays the widget TOC, but for the post that doesn’t work there is no widget displayed, which is consistent.
    Working post is –
    Non working post is –
    I have set to exclude TOC from all and to use short code only for those posts which I choose. I am using the short code [toc] in both posts.
    What am I doing wrong ? Hope you can help.

    • Mike T says:

      That’s very strange that it’s only happening on one post (particularly when other posts work). I’ve had a look but I’m not quite sure what would be causing it at the moment. I’ll try copy/pasting the content on the post that isn’t working.

      As far as I can see, they’re both posts (eg the same content type)?

      • Mike T says:

        From looking at the HTML source for the pages, it would appear that the heading tags are going over multiple lines. You should put them on the same line. eg:

        Rather than the following:

        is a 

        Please put them on the same line like:

        <h3>this is a heading</h3>
      • Peter says:

        Hi Mike T. Looks like we are crossing in the mail. Many thanks for your reply, this ties in with what I discovered by copying and checking text format. Again, many thanks for your very quick response.

  33. franky says:

    I was wondering if is possible to split the TOC into two columns when the list becomes too long? thanks

    like this

    1. 4.
    2. 5.
    3. 6.

  34. Pingback: Table of Contents Plus 1111 on Remembrance Day | dublue

  35. This is the best plugin I have come across. However I see an issue with Forefox. In the site www[dot]charlottehonda[dot]com when I look at the home page in Firefox, the TOC appears distorted. In other browsers it works just fine.

    Please help me.

    • Mike T says:

      I had a look but couldn’t find the TOC. Can you link to a page with the TOC with the issues? The TOC mostly inherits the styles from your theme. Ps, I use Firefox as my main browser.

    • Mike T says:

      Cool – I was going to suggest you try float clearing for situations like this where you have divs/sections nearby rather than pure content. Eg:

      <br clear="all" />

      Good job!

  36. Juozas says:

    Hello once again Mike,

    Not sure if you already have a fix for it but the issue with repetitive headings really bothered me. Here’s a rather simple solution I came up with:

    It seems to work, yet needs to be inspected more carefully. Thanks again for a great plugin!

    • Mike T says:

      Cool! Was thinking about using string lens, positions, etc. Also thought about using a count parameter as that found in str_replace. Rather than substr_replace, I’ll try using multibyte friendly functions for our non latin character set friends.

      A new release is scheduled for this month and thanks to you, this bug bear will hopefully be goooone!

    • Mike T says:

      Not right now but you’ll be able to do it with the next release. The enhancements to the TOC shortcode will let you do that on a per instance (page, post, custom) basis.

  37. Hi Mike,

    Thank you for your efforts creating great plugin!

    Is there any way to disable inclusion of sub-sections in TOC?
    For instance, I want only <h2> – headings to appear in TOC without inclusion of all smaller subheadings, like <h3>

    • Mike T says:

      Sounds similar to this. Seems common enough that I’ll have to think about making it easier to do this via some options in a future update.

    • Mike T says:

      Unfortunately, repeated headings on the same level are a known problem. My only recommendation for now is to avoid them where you can.

      It is a problem that is high on my list of things to address.

      Crappy response I know πŸ™

  38. Hello and thanks for this plugin. I have recently installed it on our website.

    I have a question, though. Is there a way to add a “Back to Top” link after each of those parts of the post?

    • Mike T says:

      Not currently but it is on my todo list. There have been a couple mentions in previous comments. In the meantime, there are some existing back to top plugins if you’d like to give them a try.

  39. Paul says:

    Is it possible to make the TOC horizontal vs vertical? I have a dictionary that I’m adding, and would rather orient things across the width of the page vs down it.

    • Mike T says:

      You can’t do it with the admin options provided but with some CSS knowledge, you could try placing each item on the same line (display: inline) and adjusting some of the margins/paddings to give it some better readability.

      Not sure if that’s quite what you meant but good luck.

      • Paul says:

        Hmm, I’m not very CSS savvy, but will poke around to see if I can figure it out.

        Might be a good option in a future release!

Comments are closed.