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.

Description

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.

Translations

  • Australian English (default)
  • Dutch – Renee
  • French – Jean-Michel Duriez
  • German – Ben
  • Polish – Jakub
  • Simplified Chinese – icedream
  • Slovak – Boris Gereg
  • Ukrainian – Michael Yunat

Translations are more than welcome. The translation file can be found in the languages folder of the plugin, or online in the WordPress repository.

If you have any advice in making it easier to translate, please let me know.

Screenshots

Scenarios / FAQs

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

How do I disable the table of contents for a certain page?

Simply add [no_toc] anywhere on the page to suppress the table of contents.

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 /wiki/).

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:

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

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.

Shortcodes

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. The following parameters are accepted:

  • 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.The following parameters are accepted:

  • 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, when set to false, does not split the posts by first letter.

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.

785 thoughts on “Table of Contents Plus”

  1. Seriously killer plugin, really adds a tremendous amount to my site. Thanks! Would it be possible to have the TOC wrap right ONLY if it is less than let’s say 50% as wide as the container, and otherwise to take up 100% width?

    1. Nice to know it’s added some value for you.

      The behaviour is possible but will require custom javascript to run after the page loads to compare the widths of the TOC container and that of the content area and adjust to suit.

      1. It wouldn’t solve it as it only solves one unknown. The other remains the dynamic width of the TOC which can only be determined after the document is loaded in the browser. Don’t forget, a lot of themes these days adjust the widths on the fly dependent on the user agent used (eg mobile, tablets, widescreen, etc).

  2. Hi, I’ve downloaded the TOC+ plugin and have adjusted all the settings to what I think should work but the table of contents still isn’t appearing on my site.

    I would like to have it on all pages except for the frontpage and I have specified this in the widget options.

    Also, is there an option to show the children pages only on the category you are currently on? I would like for all of the categories to show all of the time but then for example, when you go into the ‘Adopt / Sponsor a Dog’ page, I would like for the rest of the pages (like the names of each dog) in that category to show.

    Thanks for any help you may be able to offer

    1. I had a quick look at your site but couldn’t find any pages with headings. You need to make sure you’re using headings and that you have at least the minimum number of headings (default is 4) on the page before a table of contents will be generated. The heading options can be found in the first drop down box after expanding the kitchen sink in the visual editor.

      Re your second question, I think you’re referring to a sub page/category listing which this plugin does not do. There are many ways to achieve this (eg via code with get_pages, wp_list_pages, get_categories, others or easily with plugins), try googling “wordpress sub page list” which will give you a few to go on.

  3. I really like this plugin and it looks like the best TOC out their for wordpress but it doesn’t work for me! when i activate it all the pages i want to add TOCs to just end up being white blank pages. its not just the word press page thats blank but the entire webpage is completely blank. but the odd part is that if i go to my other pages that i don’t want a TOC on they are completely fine.
    I think theirs a problem with the pages that have headings on them. I’ve never used headings until now and all the pages that have headings on them wont load with this plugin installed. i cant even preview the pages to see if it added the TOCs! any help?

    1. Ahh the dreaded white screen of death. This can occur when PHP has exhausted available memory and is most prevalent in the cheaper hosting options as they tend to limit the amount available. Check out http://ocaoimh.ie/2012/05/16/fatal-error-allowed-memory-size-of-67108864-bytes-exhausted/ and see if the tweak provided help.

      Otherwise, I would suggest to check out the error logs for the exact cause and paste it here if need be. The error logs should be available via your cpanel or equivalent.

      1. Hey thanks for responding. I looked into the link that you sent me and the only problem is i have no idea how much memory to give PHP. it says their that an error pops up but it doesn’t show anything for me.

        also i would love to check out the cpanel but i’m not really the owner of the site. some buddies on my video game server own it and they gave me the account info for the admin wordpress account. They don’t have experience with wordpress so i was building the site for them :P

      2. I would suggest to try the value suggested (128M) then up it if need be. Your milage may vary as some webhosts place a hard limit.

        If the above doesn’t work, you really need to get access to the web server error logs as it will tell you exactly what the problem is. Without cpanel, you could try looking for it via FTP but unfortunately, you won’t be able to get it using WordPress.

  4. Hello, I read the above comments about using the section numbers as the anchor link and it works out much better for me because my section headings are quite long.

    Anything which shorts the anchor name to 16 or so characters would be greatly appreciated.

  5. Thank you for great plugin! Any ideas how I can apply floating for the generated toc? I need it at the left or right of my post. Thank you!

  6. Hi,
    great plugin.
    In the [toc] would it be possible to add a point after the ordering number for the first level. I would like the [toc] to look like this:
    1. Heading 1
    1.1 Heading 1.1
    1.2 Heading 1.2
    2. Heading 2
    Where could i adjust this in the source code myself?

    1. I’m sure it’s possible, you’ll need to weigh up effort vs result but I don’t think it’ll be a one line change. Before you add the trailing dot you’ll need to ensure that the prefix is an integer with no dots which is OK but factor in hierarchies then it gets complicated as there’s alot of looping involved.

  7. Coming back to the style of numbering the toc headings: would it be possible to pass the option ordered_list=’false’ in the [toc] shortcode? Then I would be free to have my own style of numbering.

    1. It doesn’t actually use ol for the lists but ul so automatic numbering isn’t added by the browser.

      However, have you tried turning off the ‘number list items’ option and then supplying custom CSS to customise the numbering scheme? Eg CSS:


      #toc_container li {
      list-style-type: upper-roman;
      }

  8. Hi!
    This plugin seems awesome but I cannot get it to work quite the way I want to.
    I would like to have a TOC of all my posts on my archive or category pages. Can this be done?

    Thanks for your great work!

    1. The headings that are displayed in the TOC all look like they were marked up as heading 3s (h3). Did you only include h3 in the advanced options? The nesting comes in when you have other level headings. I would suggest to leave all headings enabled under your advanced options which will let you empasize on content structure.

  9. Hi, this is a great plugin which I’ve integrated today.

    One suggestion I have would be to add CSS classes, according to the header level it’s linking to, so the table of contents could be custom-styled.

    e.g. …

    1. That’s a good pickup. I’ll make sure it does not fire in feeds. Can’t see why people would want it there to begin with.

      1. Hiya,
        Thanks for the update! It’s there now :)

        One more think I was wondering, might be useful for some of your users. I prefer to style things myself through the style.css file. So, if you could just throw in an option for that (under the presentation, with some name like “Do it yourself”) then it would be really great. As you can see, I have set width, etc myself, and using some jQuery plugin for “sticky scroll” of the TOC (as you can see here: http://www.intechgrity.com/howto-rotate-and-flip-images-in-php-using-gd-retaining-png-transparency/). Right now, I have used the hackish !important overriding CSS rule to apply my styles. I know, I can just wp_deregister_style, but an option on the plugin would be a neater way to do that. Just a thought :)

        Thanks again for the update.

      2. Hi Swashata – that link looks really good and I’ll take that suggestion to disable all CSS related stuff on board. Some others have asked for it as well.

  10. I’ve translated 1112.1, sadly I didn’t find translator so I just edited the toc.php and distribute without your permission…Apologise for my impoliteness.
    Just wondering will you create a .pot or .po translator?
    Great thanks for your toc extension, easy using and powerful configuration.
    (Forgive my poor English.:sad:)

    1. I would love to make it internationalised but I’m a newbie when it comes to that as we only need to worry about English in Australia. I’ve tried to make it translatable by using __ and _e functions where possible (maybe not the help tab). I’m uncertain on getting an environment setup to display other languages, if the language selection will be automatic, or will it fallback to English, etc. Also not quite sure what tools to use to validate any of this. Happy to receive advice on any of this? Maybe I should just read http://codex.wordpress.org/I18n_for_WordPress_Developers more thoroughly…

    2. I’ve just uploaded some i18n compatibility changes and have generated a pot file which lives in the languages folder. You can check it out from the development version available at http://downloads.wordpress.org/plugin/table-of-contents-plus.zip

      I don’t know anything about these mo and po files though. Let me know if I’m heading in the wrong direction.

      After you’re done, I’ll add it to the pack and attribute the translation to you.

      1. Thanks, it works. :)
        It is easy to translate if you offer the .pot file, as I can use POEdit and import translate keywords from the .pot file. Though most of the time spending on the translator’s name, finally got that it should be toc+-{locale}.po. So I think it would be easier if you name the .pot file to toc+.pot.:P
        Anyway, I’ve uploaded files here. Two places I’ve tweaked :
        1. Line 753, adding “toc+” so the sentences are translatable.
        2. Line 834, moving “the_content(). ” back, for easier translation.

  11. Howdy,
    Thanks a mint for taking the TOC out of RSS feeds – Much nicer! I’ve noticed though that when pasting a URL from my site into facebook/google+, the description generated contains the TOC. Could the next version prevent this as well?

      1. Yep as Swashata suggested, this is due to your theme or SEO plugin trying to pull out an automatic description for your page/article. It is being inserted as a meta name=”description” header tag.

        The solution would be to find out if it is being triggered in the header part of the html and if so to not execute the TOC stuff but so far I haven’t found a way. I’ve tried experimenting with is_main_query introduced with WordPress 3.3 but it doesn’t give me what I want.

        So the solution for now is to make sure you add a description to your articles, rather than let it fallback to automatically creating one.

  12. Hi Mike, great plugin.

    Using WP 3.4.2 theme Intent from Themeforest and WPML for translation.
    Links made by [toc] in content runs OK, but Toc+ widget makes id with a “-2″ append at the end, so it doesn’t jump to the desired link.
    Thanks in advance for four help.
    Arturo

  13. Hey, great plugin! Unfortunately, it doesn’t work on my new server with PHP 5.4.5:

    Fatal error: Call-time pass-by-reference has been removed in /xx/plugins/table-of-contents-plus/toc.php on line 1239

    Thanks!

  14. Hi,

    thanks for writing this plugin!

    I have started a german translation (141 translated, 12 fuzzy, 40 untranslated). Where should I upload it or to which email should I send it?

    Some strings were quite difficult to translate, as I am not quite sure about the context. Others seem to be impossible to translate properly, as you seem to generate sentences piece by piece. But I have to apply grammar to generate a good translation.

    Cheers,
    Martin

  15. Hi and Thank you for your great wp plugin !
    Therefore I wonder how to make valid my anchor (with accented characters like “é” or “à”).
    When my H2 contains no accented characters, all is all right.
    But when my H2 contains an “é” ou “à” or whatever accented characters, the anchor in HTML code delete the character making the anchor not working.

    Is there a way to make it ok ?
    Thank you in advance

    1. @Vince, yep it strips out non ASCII characters from the anchor as recommended in the HTML spec but it should still create an anchor that works. If it’s not, please send me a link and I’ll take a look. Please note that this is similar behaviour on other sites like Wikipedia.

  16. The guides are frustrating because they don’t say how to use no_label and other commands. Where do I place all this stuff? For example, if I want a certain heading not to show up, would I do this:

    [toc no_label: true]…[toc]

    I’m not sure how to use the commands with the tags and there are no examples that show code with interface.

    Also, can I make a TOC span several pages? I can’t find documentation that spells out how to do this. I only see in-page tables.

      1. @Robert, the table of contents doesn’t allow you to hide specifically titled headings. The plugin does, however, let you exclude heading levels, eg exclude all h3 tags. You can do this in Settings > TOC+. The alternative is to not mark the title you want excluded as a heading.

        The no_label property you were playing around with lets you hide the title of the indexes at the top (eg “Table of Contents”).

        In most cases, I tell people to avoid using shortcodes eg [toc] to reduce complexity. You should only use the shortcode if you need to override the settings you have set in Settings > TOC+ on a per page basis.

        Finally, this plugin creates a table of contents for the current page only – ala Wikipedia.

  17. Hi
    I have generated a sitemap, but at the bottom of the page it lists all pages, categories and tags making the page rather cluttered. How can I hide those three columns?

    Sincerely
    Geir Rosset

    1. @Geir, I’m assuming you’re using the [sitemap] shortcode? If so, it should only be printing out all pages and all categories. Tags shouldn’t be included in that listing. Do you have a link to what you mean with the three columns?

      1. @Geir, do you have another sitemap plugin installed? Does your theme provide you with sitemap related functionality (eg you via a page template)? Do you have sitemap widgets? The reason I ask is because all sitemap related output from this plugin is enclosed in a specific HTML div class and the three columns at the bottom are outside.


        <div class="toc_sitemap">
        ...

      2. Yes my theme has a sitemap page template, but I did not use it in this case. I used a standard page template. Is there a conflict when using the [sitemap] shortcode?

      3. There shouldn’t be a conflict. You can test by taking out [sitemap] from your page and see if the three columns at the bottom still appear. If so that means it really is being provided by the theme. I would then suggest to check out the options available with your theme. Maybe there’s some theme options you can tweak, maybe something part of the theme doco? As a last resort, you could always hide the three columns using CSS but stopping it from being outputted should be your goal.

  18. THANK YOU. I usually don’t take the time to write letters of thanks to plugin creators but I just wanted to say thanks b/c it’s nice to find a plugin that works and is simple/easy to use. Your TOC+ has saved me a TON of time. I only wish I would have found it quicker in search.

    Thanks so much!

    PS If you are available for development, I’m looking for a good developer to work with, please email me. thx

  19. Hi Mike, thanks for your awesome plugin. I really *love* it, especially all the customizing options.

    One thing I failed to customize though: I would like to style the generated numbers via css, for example add a bit of right padding or margin to leave more space between the number and the title.

    If you could just wrap the numbers in some html tag (span would do), one could easily apply css styles to them – like changing color or adding some padding.

    That should take no more than two minutes…

  20. I’m creating a theme which has some page templates that not only contain the standard entry text (i.e. the_content()), but also generate some additional text below. The additional text is generated by performing a custom WP_Query and outputting the results, so the code contains a custom loop containing title tags (h2, h3, h4 etc.) as part of the output.

    Is it possible to use your plugin to create a table of contents for the entire final rendered page? I think right now it only looks at the contents of the_contents() rather than the template as a whole?

    1. @David, are you able to do your custom work by making use of the_content filter? If you can, make it run before 100 and append your content to the page’s content and it will be picked up by the plugin. Here’s a very brief example of what I mean, add it to the top of page.php or similar wrapped between php tags. Btw, I haven’t tested this but it should work and makes sense in my head…


      function my_custom_function( $content )
      {
      $content .= 'append my custom content to the end';
      return $content;
      }
      add_filter( 'the_content', 'my_custom_function', 99 );

      If it doesn’t work, then currently there isn’t a way to call the needed functions entirely. Right now, you can only pull the TOC index but not the altered content with correct anchor links next to the headings.

      1. Thanks for the bright idea Mike, your suggestion worked a treat, and provided me with a previously-unknown method to manipulate content in my templates. Many thanks!

  21. Hi mike,

    As everybody here i would like to thank you for this plugin, it just gives me what i wanted.

    But i (as everybody here!) do have something to ask you :

    I encounter a strange behaviour (at least for me as a newbie, i am sure you will find out what is happening in a minute or so) when using TOC+ :
    – I do not use numbered list (i numbered my heading myself). The bullets in the TOC table are actually outside the table…

    Here is a link that is clearer than my explanations :
    http://cavepopo.hd.free.fr/wordpress/bash/about-regular-expressions-basic-extended-2/

    I am quite sure it is something between the evolve theme and TOC+, but i need you to find out what code is messing my TOCs.

    Thank you for your plugin and your time.

    Pier B.

    1. @Pier, yep the bullets are coming from the theme but you can use some custom CSS to override it. If you don’t want any bullets in the table of contents at the top, try:


      #toc_container ul {
      list-style-image: none;
      }

      Or if you want the bullets to appear for nested lists, then also add the following:

      #toc_container ul ul {
      list-style-image: url("/wordpress/wp-content/themes/evolve/library/media/images/list-style.png");
      }

      You could also experiment with the margins or paddings for #toc_container.

      1. So i did include the code you provide, and of course it works just perfectly. Thank you.

        I do have another question, to which i clearly remember seeing the answer somewhere (must be here) but i could not find it, so i have to ask you the same question, sorry for that :

        – Why is the TOC (wrapped to right) cannot be aside of a heading ?
        I am not sure i am clear… so here is a post that shows what i tried to explain : You can see in this post that the first heading (1 Generalities) is shifted / moved down when the TOC is unfolded, and the same heading comes back to its supposed location wghen the TOC is folded…
        http://cavepopo.hd.free.fr/wordpress/network/about-cryptography/

        Waou that was hard to explain !

        Hope you got it.

        Pier B.

  22. I have smooth scroll enabled and excluded the CSS file.
    Everything works fine but when I change the ‘Smooth scroll top offset’ from the default 30px to anything else, the plugin stops functioning i.e. TOC is no longer generated.
    Ideally I need an offset of at least 50px as I have a fixed menu bar at the top.
    Development site URL: http://safari-uganda.com/gls

  23. Hi. I’m excited to get your plugin working, but I’m having trouble.
    I added a TOC to http://www.getimaginality.com/help/create/terengganupilot/ and it appeared and looked good. But all the links are broken. E.g. the “Software” item takes me to http://www.getimaginality.com/help/create/#Software (note – it is missing the /terengganupilot/ part of the link).
    So I tried manually typing in http://www.getimaginality.com/help/create/terengganupilot/#Software and it worked perfectly.
    So I viewed source, copied Software and pasted that outside of the TOC, and that works!? Even more odd, is that when I view source, my manual link has been automatically expanded to Software in the html, whereas the original link in the HTML is still just Software. When I disable your plugin, I get the same result, so something else is doing the automatic expansion.

    Any suggestions would be appreciated. To get a quick result, I have copied the relevant source and pasted it manually into the page, and disabled the plugin. If it helps, I’m using Chrome, and WordPress is up to date and has quite a few security plugins, plus Ultimate TinyMCE, PJW Mime Config, Google XML Sitemaps and bbPress.

    1. I’ve had that exact same behaviour before and it was due to the Google Analytics plugin I was using, check out http://dublue.com/plugins/toc/comment-page-2/#comment-1124

      I checked your site and you’re using the same GA by Yoast plugin as I am but the internal anchor links are still being changed by something. I would suggest to try disabling SEO related plugins one by one and if you find which plugin, please let me know so I can check it out.

      If you still can’t find what the cause is, try getting TOC+ to run later in the process by changing the number 100 to something higher (line 132 of toc.php). I would still suggest to find which plugin is causing it otherwise you might be doing that hack with every new release which is not ideal.

  24. Great plugin, and it can still have some speed optimization on client side:

    This plugin loads one styles, 3 scripts on my site. however screen.css can be disabled and inserted into theme styles. The other 3 scripts are all small and can be compressed and combined into one file to reduce HTTP requests.

    1. @Tunghsiao Liu, thanks for raising that – yep, I was aware of them but figured the most passionate of performance tweakers would have ways to combine them :) eg total cache, wp-minify, web server cache controls…

      But its the second time this has been raised so I may as well combine and minify the js files :)

      1. Good, I tried wp-minify but TOC’s styles and scripts cannot be combined with others. It seems that you’re using some uncommon way to include your styles and .js files?

      2. Nope I’m using the standard WordPress script and style enqueue methods. Nothing out of the ordinary there. But I’ll enable wpminify when I get a chance and see if I can see what’s going on.

  25. Great Plugin Mike,
    A feature suggestion I have is to have the page/post title as an option for the title of the tabe of contents. For example I have a page titled about acme tools. I have a sidebar that is applied to all pages. I would love it if the contents title was the same as the page title. I may take a stab at adding that feature myself as that would be be huge for how I am using it.
    Again, many thanks.

    1. @Peter, that’s a neat suggestion and seems fairly easy to implement. I’ll look to add it if you haven’t, am thinking of allowing the title to be set with a substitute variable, eg “%PAGE_TITLE%” which will also allow custom text to surround should the need arise.

  26. How does the eclude function work as i cannot get it to stop showing the Welcome ( login ) line when i use [sitepages]
    I use short urls for pages so i have tried [sitepages exclude=/login]
    ive tried exclude:login exclude=/login/ but it still shows up.

    Do i have to use id’s for the pages to exclude ?

    Thanx in advance
    Justine

      1. Yep I’ll put that in – I had originally (1yr+ ago) wanted to allow for easy exclusion but never got around to it. When I mean easy exclusion, I want people to select from a list of current pages rather than to find the page ids.

    1. I imagine you were referring to the suggestion made by Tux? Yeah that would be easy to do – only hardest part is to figure out where the admin option will lie. I hate clogging up the options as I prefer to keep it user friendly/easy to use.

  27. Hi,
    I’m sorry if you already discussed it, but I need to be sure for the answer.
    I’d like to install a plugin that allows the users to add rows and fill up the content.This is for their CV.
    Can I use your plugin for that?
    Thank you so much for your time.
    Best,
    Prolet

    1. @Prolet, nope, this plugin creates an automatic table of contents (the index you see at the top of this page) based on the headings (h1-h6) you used to create your page or post. It sounds like you want a resume type of plugin and there were some available. If you’re doing from scratch, then you’ll need a custom form with all the fields you need, then a means for it to be submitted as a drafted post (or custom post type). The TOC+ plugin can be used at the end of the process during printout to create an automatic list of headings at the top.

  28. Hi Mike
    Love the plugin but struggling to get it to work properly. Doing strange things like adding additional numbers where there is no heading, skipping heading and using it on the next number etc. Some are perfect! Would really appreciate if you could have a look and tell me if I am doing something wrong?
    Thanks
    Peter

    1. @Peter, I had a check of a few of your trimmer pages and can see the blank headings. I checked your source and you have blank headings in your content. If you remove them, the blank headings will disappear. You can remove them by switching over to HTML mode, and removing the line totally. For example, on http://electricstringtrimmerreviews.net/toro-51486/ search for the heading ‘Auto-Feed Trim Line’ and remove the <h3></h3> above it. You’ll need to do this for all blank headings.

      Btw, it looks like you are pasting your content from Microsoft Word? Blank headings and many unneeded span tags are a result of copy/pasting from Word as it copies all the fluff that Word puts in.

      1. I couldn’t find any blank headings but found a bit of text that was styled like a heading but isn’t marked up in HTML as a real heading. The bit of text is “Built-in Auxiliary Handlexxxxxxxxxxxxxxxxxx” and marked up as:


        <p> <br>
        < style="text-align: left;"><span style="color: #008000; font-size: 16px; font-family: verdana,geneva;"><strong><span style="text-decoration: underline;">Built-in Auxiliary Handlexxxxxxxxxxxxxxxxxx </span></strong></span></p>

        It should rather be something like:

        <h3>Built-in Auxiliary Handlexxxxxxxxxxxxxxxxxx</h3>

  29. Thanks for this great plugin! It would be great if there were a way to make the TOC only work for certain classes of headers. (I often use h4-h6 as fonts, and would like the TOC to only register h1-h3…)

    Thanks again!

  30. Thank you for a brilliant plug-in.
    One comment – You should advertise more that it can display it in the sidebar only – I didn’t notice this when researching plug-ins to use, and only noticed it when I went to the widgets area thinking I was possibly going to have to do some hacking!

  31. I really like this plugin, but I just noticed a bug which I didn’t see when I first started using TOC+: The JetPack plugin includes a sharing option, which puts a section at the bottom of a post with links to social media sites (e.g., Twitter, FB, etc.). Because JetPack wraps this in , TOC+ picks it up and puts it as part of the contents, which I definitely don’t want, while I do want to include my post’s headings. Example: http://xoph.co/20121028/super-tweet-1/

      1. So from the link you provided, you don’t want to include “4.1 Share This”? My hunch would be there would be two camps on this, some would like to include it while others wouldn’t. I’m not sure if I can add an option here… just depends on what hooks Jetpack add to the heading.

  32. Hi, I am trying your plugin and I am stuck

    i have created 5 posts (each has 2 or 3 headings ) and [toc] displays those 2 or 3 headings fine on the page

    however, i would like to have [toc] to display all headings from all posts on every post
    not only headings from that single post

    as far as I am aware, it is possible, but can’t find a way how to do it..

    my issue if I was to use this plugin, is I would like to use this plugin only on one section of the site, one part of the site with 100 or so posts
    I would like it to be a ‘book’ (so I can’t enable the plugin on all posts/pages)

    how shall I go about it?

    thanks
    kris

  33. Hi Mike

    First off, thank you for an amazing plugin! I have a few questions:

    How could I change links to come out with hyphens instead of underscores (hyphens are more SEO friendly). For example instead of have links like domain.com/post#this_is_a_header it should be domain.com/post#this-is-a-header

    Could you tell me where in the code I could change this?

    Another thing: The Danish word for apples are “æbler” but TOC+ doesn’t recognize special characters like “æ” … a header called “Æbler” would come out as domain.com/post#bler – instead I’d like the link to be domain.com/post#aebler. Is there any way to add a few special conditions? For example:

    if æ then ae
    if ø then o
    if å then aa

    Best regards
    Jan Kaczmarek

    1. Although I agree that the use of – instead of _ has a slight advantage when it comes to SEO for page names, I don’t believe it applies in this case as we’re no longer dealing with the resource location, instead we’re playing with the local in page anchor (the fragment, or named anchor). But that’s just a matter of opinion as there haven’t been any conclusive evidence or advisory that extends the use of – to anchors. Additionally, I’m not sure how relevant this is these days as I wonder why Wikipedia doesn’t do it?

      But the good news is that it’s quite easy to change, on line 1059 of toc.php, change _ to – and you’re done. I’m not sure if I’ll put this in as an option as I’m not sure if it’s a problem to be solved…

      As a FYI, you should check out my article on Google’s in page jump links.

      Re special characters: earlier versions supported non ASCII characters for anchors it didn’t work for some smart phones and tablets. It also was against W3C recommendation http://www.w3.org/TR/html4/struct/links.html#h-12.2.1 so anchors are now restricted to ASCII. This is not dissimilar to Wikipedia articles. Mouse over the TOC entries at http://de.wikipedia.org/wiki/Deutschland and you’ll notice that none of the special characters have carried through. If there is a nice library that handles common special characters to ASCII translations, I’d like to consider putting it in.

  34. Thanks for answering my questions, Mike :) I really appreciate it.

    I tried changing _ to – and it worked. Thanks! :)

    SEO benefit or not regarding underscores vs. hyphens, I think it’s prettier with hyphens :) Also, you can’t get a domain name with underscores – only hyphens – and you can’t get domains with uppercase characters either, which leads me to another question: Is it possible to convert all uppercase letters to lowercase.

    If Wikipedia does something it doesn’t mean it’s correct or good. Wikipeda is built on a CMS like most sites and all CM systems have flaws.

    WordPress must use some kind of library that converts special characters/letters to ASCII. E.g. if you make a post title called “Æbler” the permalink will be “domain.com/abler”. Über will be “domain.com/uber” and so on. Do you have a quick solution if I say I want to convert æ to ae, å to aa and ø to oe? I could also ask some of my PHP-savvy friends; I don’t want to waste your time of course :)

    /Jan

    1. To make it all lower case, underneath that line, add

      $return = strtolower($return);
      

      It’s good to know that WordPress does the character translations already. I’ll check it out to see if I can leverage it.

  35. Waouh! Great plugin which does exactly what i wanted! Congrats! 2 questions however:

    1- For some reason, when I click on one item of my table of content, I end up in the middle of the title. Which is not the case when I see other examples, on your demo site for example. Is there a way to adjust this? I would like to be able to read the title (a bit below).

    2- Also I have tried, but it seems like it is not compatible with Wysija plugin, do you confirm that?

    All the best
    Olivier

    1. @olivier, your first question is easy. I’m guessing you are logged in and have the admin bar displayed? If you enable smooth scroll, it not only scrolls to the anchor, but also adjusts itself such that the heading should completely appear.

      I just tried the Wysija plugin and can confirm that TOC+ does not work with it. I believe Wysija doesn’t run external shortcodes nor apply the_content which is what TOC+ uses to do its thing. This would be something to follow up with the Wysija author. Nice plugin tho!

Leave a Reply