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.

784 thoughts on “Table of Contents Plus”

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

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

      1. 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!

  2. 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?

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

    1. 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 :(

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

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

  4. 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: http://pastebin.com/TDp7vnC5

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

    1. 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!

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

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

    2. 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!

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

  7. 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 – http://www.raski.co.za/2011/06/try-blogging-it-is-fun/
    Non working post is – http://www.raski.co.za/2011/11/around-the-world-%E2%80%93-week-1/
    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.

    1. 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)?

      1. 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:

        ...
        <h3>this 
        is a 
        heading</h3>
        ...
        

        Please put them on the same line like:

        ...
        <h3>this is a heading</h3>
        ...
        
      2. 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.

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

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

  10. 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 (http://ulrichpalha.com/myblog/) 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.

    Thanks,

    Ulrich Palha

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

  11. 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?

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

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

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

    1. 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!

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

  12. 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 ?

    thanks

  13. Hi Mike,

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

    code in TOC:

    [code]http://thedukandiet.info/vegetables-dukan-diet-attack-phase/#Garlic[/code]

    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.

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

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

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

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

  15. 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)

    Fran

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

      define( 'TOC_MIN_START', 3 );

      to

      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.

  16. Hello,
    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.

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

  17. 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!

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

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

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

      1. 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 :)

  19. 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?

    1. 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 :)

  20. 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!

    1. 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+.

  21. 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 http://proactolweightmanagement.com/ , 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 http://proactolweightmanagement.com/comprehensive-reviews-on-proactol-plus/ – 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.

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

  22. 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:

    http://amsecsafes.com/pharmacy-safes/pssw-pharmacy-safes/

    takes you to this page:

    http://amsecsafes.com/pharmacy-safes/narcotics-safe/

    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?

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

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

      1. 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!

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

      3. 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!

  23. 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 :)

  24. 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
    http://wordpress.org/extend/plugins/indizar/

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

    http://mognet.no-ip.info/wordpress/2011/04/qnap-659-pro-ii-nas-review/

    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 :{

    1. Yep I’ve noticed this before as well. Basically WordPress is only feeding the displayed content when it runs the_content which is what this plugin uses to insert itself. This means that it already has paged the content and only providing what should be displayed.

      This aside, I agree that it should display a TOC for the entire page including those that are paged out. Doing so won’t be a trivial task though.

      The question I’ve now got is: should the TOC appear on every page that is paged or only on the first?

      1. Personally, i’m in favor of adding the TOC to all pages.

        Makes sense because when you go to the next page, toc is gone. Then you don’t have the benefit of clicking from toc to go to the page you wanted.

        Then you are back to resorting to using the numbered pagination wondering what the heck clicking that will bring you to.

        here is a pulldown toc i like
        http://www.trustedreviews.com/samsung-ue55es8000_TV_review

        This other one is similar, but adds a next page link as well, with the title of the next page toc header
        http://www.anandtech.com/show/5541/amd-radeon-hd-7750-radeon-hd-7770-ghz-edition-review

        This one combines a big tabled toc at the top, and a pulldown at the bottom

        http://www.tomshardware.com/reviews/ssd-520-sandforce-review-benchmark,3124.html

  26. 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…

    mysite.com/#myanchor

    instead of looking like…

    mysite.com/mypost.html#myanchor

    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!

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

      1. 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…

        /%category%/%postname%.html

        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?

        Thanks.

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

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

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

    1. 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 :)

      1. 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!!

        Marc

  29. Hello,
    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.
    Thanks!

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

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

    1. Yes, the comment just above yours is the same thing. I have been working on it and it will be addressed with the next release.

  31. 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 :)

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

      1. 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 :)

  32. 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 http://www.christchurchtonbridge.com/messenger/may-2012-messenger/

    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.

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

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

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

      1. 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!

  35. 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! :)

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

  36. 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?
    Thanks.

Leave a Reply