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

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

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.

Help

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:

%PAGE_NAME%

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.

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

Shortcode Description Attributes
[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() ) {
    	$children->the_post();
    	echo 
    		'<h3>' . get_the_title() . '</h3>' .
    		'<ul>' . toc_get_index( get_the_content(), get_permalink( $children->post->ID ) ) . '</ul>'
    	;
    }
    wp_reset_postdata();

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. Hi Mike,
    Still enjoying your plugin 🙂
    Suggestion. I am making a site in which some pages are devided into multiple pages (using page break). I see that the TOC only lists the headings of the page it is on.
    Si in the case of multiple pages would it be possible to have an option so that one can choose (or not) that TOC shows all headings of multiple pages?

  2. Hi, I would like to add a toc+ to my woocommerce product_cat taxonomy archive. Is there a way to implement? I know some php.
    Thanks!

  3. Great plugin! I was wondering if you would be available for some work on the private project based on your plugin (related to adsense) ? I would love to hear from you

  4. Pingback: Sådan (kan) du designe dine blogindlæg - Unitate

  5. Hi,
    1- Thank you for a great plugin, works as expected with lots of option.
    2- Small problems
    I am just using [sitemap_posts] works as expected except Sticky post comes out at the not , I wish it would just come out at his alphabetical position.
    In French we have a lot of words with a lot of accents: they come out as a white on black question mark : not very nice !
    Thank you again and also for a great support.
    Regards from France

    • I have found an answer to first question by modifying the query in toc.php; you have to exclude sticky post by adding ‘ignore_sticky_posts’ => 1 and sticky post will appear in natural position

  6. Hi,

    Couple of questions pls.

    1- How can I underline the heading “table of contents”
    2- I would like to show the table of contents on top as well as bottom of the article. Is that Possible ?

    Thanks
    Kas

    • Mike T says:

      1. With CSS:

      .toc_title {
      text-decoration: underline;
      }

      2. Nope but with your own custom javascript, you can manipulate the DOM to includ

  7. Using TOC+ with the Genesis Framework and the Magazine Pro theme, which has a floating navigation menu bar at the top of each page. Placed the table of contents on a page using [toc] and although the TOC itself looks good, and it jumps to approximately the correct headers (I’m jumping to s only), I think the anchor point is getting covered up by the floating menu bar, making it look like the TOC jump was to the paragraph text following the rather than to the itself. Any ideas regarding how to add padding above the anchor so the doesn’t get covered up on the jump?

    The page is still in draft mode. I didn’t want it to go live until I fixed this problem.

    Paul Croll – The Aging Photographer

  8. Richard Kinney says:

    I seem to be having trouble getting the syntax correct. I’m trying to use this line:
    [sitemap_pages no_label: "true" exclude: "about"]
    But nothing changes from a simple use of [sitemap_pages], cloud you tell me what I’m doing wrong?

    • Mike T says:

      Try:

      [sitemap_pages no_label="true" exclude="1234"]

      Find the post ID for your “about” page and put it into the exclude parameter. You can get it by editing the page, and viewing the post=number in the URL.

  9. Pingback: WordPress, lists, and a pissed off WPuser - By the barrel

  10. anonymous says:

    Is there a way you can make it a reference rather than span id reference in the code? I think the SEO benefits of the plugin will be greatly increased.

    • Mike T says:

      If you can point me to some strong evidence supporting this then that’ll be great, otherwise the span technique is the same as that used on Wikipedia and its SEO has been pretty good in my opinion.

  11. Using the plugin on a very large multilingual website I did with WPML. Specifically for this plugin there is a file you can add to your plugin to be able to translate the admin texts, such as Content, show, hide, Pages and Categories. If people have WPML installed this wpml-config.xml file automatically loads, if they don’t have WPML installed nothing happens.

    I already have made the file and added it to the site o my client and it works perfect. I have made a Gist available for you to update your plugin and include this file and for anyone else looking to translate these strings and cannot wait for the next update 😉

    You can find it here: https://gist.github.com/senlin/b18cd290d9d46c8e3304

    • Mike T says:

      Thanks!

      Does this file need to change everytime the literals change (similar to the translation file for normal plugins)?

  12. Pingback: Table of Contents Plus 1408 released | dublue

  13. Hi, your TOC plugin is pretty great! Would it be feasible to allow a class= parameter so that we can change the CSS of the TOC for different sections of the site?

    Sometimes my colleagues want a vertical TOC and sometimes they want a horizontal one. The workaround for now is to set a body class each time but that’s fairly clumsy.

    Thanks for considering it,
    Joe

      • Very cool, thank you!

        By the way, if you might be interested in adding a horizontal TOC option for the non-coders, here’s some CSS code that worked for me. I called it “htoc”. (The again, maybe you don’t want to include it for the sake of avoiding feature creep and bloat.)

        .htoc ul.toc_list {
        margin-left: 0; /* line up TOC with left margin by default */
        }

        .htoc .toc_list li {
        list-style-type: none; /* remove bullets */
        display: inline; /* get horizontal */
        padding: 0 5px 0 5px; /* left-right padding between items */
        border-right: 1px solid #000; /* add a vertical line between items */
        }

        .htoc .toc_list li:first-child{
        padding: 0 5px 0 0; /* remove left padding for first item */
        }

        .htoc .toc_list li:last-child {
        padding: 0 0 0 5px; /* remove right padding for last item */
        border-right: 0; /* remove right vertical line for the last item */
        }

  14. Pingback: Tools for Coaches Run Your Business Online | Coach Premises

  15. I would really like to see a site wide TOC based on with formatting located on one page – named TOC.
    A good model is the TOC option in a MS Word document.
    There are a number of plugins that do this, but they are all out of date.
    This TOC could be a more complete version of a Sitemap.
    I would like to see formatting of your current Sitemap based on Parent & Child pages.
    You might consider Show | Hide functionality for each of the page TOC’s on the site TOC with the Admin option of initial All Show or All Hide.
    The TOC page on my development website (URL attached) is your [sitemap].
    The SITEMAP page on my development website is from another plugin that only includes Parent & Child pages, not , but does have formatting.
    The TOC would look like this:
    Page
    Page TOC [Show \ Hide]
    Child Page
    Child Page TOC [Show | Hide]
    Child Page
    Child Page TOC [Show | Hide]
    (etc)
    Page
    Page TOC [Show \ Hide]
    Child Page
    Child Page TOC [Show | Hide]
    (etc)

  16. Would be nice if you could filter category posts by category… in my case we only need table of contents for certain categories of posts.

  17. Pingback: [WP] お世話になっているテーマとプラグイン | PRO'LOGUE

  18. Hi Mike,

    As my posts are sometimes really big, I have been using your plugin for more than one year in my blog. While many other plugins “come and go”, yours have been enabled since day one!

    I did’t know how to thank you, so I decided to translate it to spanish. Is there a way I can send you the .mo and .po files??

    Regards,
    Agustín

  19. Florian says:

    Hello Mike, great plugin! It saved me a lot of time and a lot of mess.
    There’s only one little “problem” that I don’t manage to solve, which would make it ultimately perfect for me!
    My site is in german and we have lots of special characters like ä, ö, ü, ß, etc. There’s no problem in the table of contents or in the linking towards the paragraph in question. Just in the link, these special characters disappear then. Let’s say I have a link in my table of contents that is called “Lösung”. If I click it, it will perfectly bring it to my paragraph titled “Lösung” on the same page. The link in the address bar will however be something like: Mysite.com/pagename/Lsung
    You see, the ö has disappeared. I thought it just looks weird and hoped there would be a solution 🙂
    Thanks a lot and best regards.

      • I am not german but work in Germany as an Online Marketer, so I know this special case for umlauts (ä, ö, ü) and ß in URLs. In those special cases, it is a normal practice to replace these characters with its fonetic representation (ä -> ae, ö -> oe, ü->ue and ß -> ss), Eg; Lösung could be replaced with Loesung and Straße with Strasse. This method is used everywhere (there is nothing more official, for instance, that the Bundestag –> http://screencast.com/t/DR8oeeThCOo).

        Maybe you can create arrays and use str_replace to slowly accomodate the plugin to every language standard, because I believe other languages have their special approach (for spanish, however, you can just replace á, é, í, ó, ú and ñ for a, e, i, o, u and n)

        Regards,
        Agustín

  20. Pingback: Table of Contents Plus 1407 released | dublue

  21. I’ve been working in WordPress for a year and a half and I can’t believe that I have not seen this plugin, but most of my sites have been small. It’s terrific. My client was looking to have it fixed as you scrolled and like this site.

    https://generalassemb.ly/education/product-management-immersive

    I can’t see a css file and I don’t know enough php to be able to check.
    I think I can get $ if you’ve written code that’s not included. You can email me at <removed>

    I’m posting on the other forum too on wordpress.org as well because it’s time sensitive. If you can recommend any plugin that would be great but I’d be happy to give you the money.

  22. Hi there,

    I try to exclude some posts from my toc, so I’ve tried this shortcode
    [sitemap_posts exclude="1234"]
    But unfortunately it doesn’t work. An attempt with [sitemap_categories exclude="1234"] worked fine.
    So ist there a chance to either get an exclude for posts too, not only for pages and cats
    or
    to get a shortcode to INclude some specific cats and ignoring all others?

    I would appreciate any hints or solutions.

    Thanks a bunch. 😉

    Nina

    • Richard Kinney says:

      I would like to see and include option also.
      I’m trying to setup 2 indexes for 2 specific categories. If those are the only 2 categories I have I could make it work. And include argument that would only include that category would work wonderfully.

    • Mike T says:

      Take a look at the Help tab “I’ve set wrapping to left or right but the headings don’t wrap around the table of contents”

  23. TOMO says:

    I am happy if this forum is still working.
    I want to change default offset(about 5 px).

    I style heading by css.
    Now,only half part of heading is visible when I click table of contents.
    Is it possible?

  24. JMD says:

    Hello,
    I installed your plugin and it works perfectly. I created the translation files .po and .mo for fr-FR. I would be happy to send you these files if you wish.
    Warm greetings from the south of France.
    JM

    • Mike T says:

      Hi JMD, I replied by email but it bounced twice so please send the files to me on michael /at/ dublue dot com

      Thanks

  25. Zoltan says:

    Hi Mike,

    Great Plugin! Thank you.

    Have two questions:

    1. How can I disable the TOC to show in the post if I have it in the sidebar already?

    2. Also, I would like to move the TOC to the right side of the article. Is it possible?

    Thank you for your help.

    • Mike T says:

      1. When you dragged the widget across into the sidebar, there was an option to limit the display to the sidebar.

      2. If your theme has a right hand side sidebar then try that. Otherwise you’ll need some javascript magic to anchor it to your preferred area on the page.

  26. Love this plugin, i’ve tried several with same function, this is the most easy to use and flexible. but i came across a problem. When i use to turn my post into multiple pages, the plugin will only show the toc of the first page, it would be great if this can be fixed.

    • Mike T says:

      That plugin you linked to was a fork (copy) of mine with the author intending to add support for nextpage which I believe he has done but it doesn’t look like it has been kept up to date. Perhaps it was more difficult than originally thought – which isn’t reassuring, particularly for me with hardly any time these days.

      Also, I’ve come across many sites (mostly of product/article reviews) that are split into multiple pages and they have different ways of linking to other pages. Some were drop downs, others printed out in one list, some were split into multiple columns. It’s hard for me to accomodate all of these presentation options for little gain. Ideally, they should be controlled in the theme and not the functional plugin.

    • Mike T says:

      If you meant having a show/hide option for the whole index, then yes it’s there.

      If you meant hiding whole sections of content, then not with the options provided from this plugin. However, with some custom javascript, you would be able to. I saw a post somewhere that someone had provided to do exactly this (forget where – sorry).

  27. Pingback: Mon Top Plugins WordPress Gratuits / ExtremRaym

  28. Pingback: | Financial Freedom For Nigerian Youth

  29. Realtorfest says:

    I’m sorry if you’ve answered this question a million times, but I was wondering how one might collapse a large TOC? The page I am trying to index has well over 50 sections and there is a lot of scrolling in just the TOC. If I could collapse it or display it in pages that would work perfectly. Thoughts? Suggestions? Did I miss something in the set up? Thanks so much. This is a GREAT plugin.

    • Mike T says:

      If you enable the “Allow the user to toggle the visibility of the table of contents” setting then your users will be able to hide it for themselves. You could also default it to hidden for all users if that is your preference.

      Alternatively, if you have some javascript knowhow, you can achieve the examples provided at http://dublue.com/plugins/toc/comment-page-6/#comment-2317

  30. Dirk says:

    Your plugin simply have a js error on my site which is blocking other js from running, can you help me with this ? where can i send you my link without place it somewhere public?

    Thank you for your help!

    • Mike T says:

      Responded by email: there was a clash with the theme’s plugin.js file which looked like it also included the same smooth scrolling function.

  31. Hi!

    Great plugin, but I wish there was a way to tell it to not queue any JavaScript dependencies. I hacked it in manually, but maybe you could consider adding it right below the “Exclude CSS” advanced option (that would then of course disable smooth scroll for instance)?

    Thanks!

  32. BR says:

    I think TOC+ has an important bug. It shows the TOC on all pages and posts except on the page which I have set as my blog home page. WP 3.9.1. When I swap my home page to a page which was showing the TOC earlier, even that page stops showing the TOC when it becomes the home page. Please tell me a way to fix this asap. I will be very grateful. Or I will have to manually make a TOC for my home page. Thanks in advance.

  33. Hey Mike,

    First of all, love the plug-in! I have been using it religiously on many of my websites. However, I’ve encountered a minor bug with TOC on one of my sites.

    The site’s theme has a consistent header, so I know I have to use the smooth scrolling option for TOC and set the top offset. This works great for all my subpages, but for some reason, the offset does not seem to work on the main homepage.

    Would you be able to take a look at my site and let me know how I can rectify this problem? Thanks a lot

  34. Pingback: Using WordPress to display my Resume | Scott Brooks

  35. Hello,

    I have a problem with a TOC on my website, specifically on the page http://hubertbrychczynski.pl/przeklady/ (it’s in Polish)

    I’m using Jetpack visibility plugin. I have put the TOC to that page in the sidebar and set it to be visible on that page only. However, two entries aren’t working – namely 1 and 4:

    1 Nieśmiałe początki: „Żółw” Juliana Tuwima (2010)

    and

    4 Przekłady komiksów – wydawnictwo Centrala (2012-13)

    Could you give me a hand?

    • Mike T says:

      I can see that there are some unicode HTML markup in the sidebar which isn’t in the content. My gut feel is that some WordPress the filters are different for sidebar and content.

      It’s nothing that you’ve done. When I get back travelling (next week), I can have a better look.

      For records, the first heading had:

      &8222;Żółw&8221;

      Eg the &8222; and &8221;

  36. Lars says:

    Hi Mike,

    first of all: I love your TOC+

    But there’s one little thing i’m asking myself. Is it possible to show the TOC after a special paragraph, instead of a heading, top or bottom?

    If you have any tipps i would be happy. Otherwise just send me an offer to my mail address

    thanks…

    • Mike T says:

      You can always manually put [toc] after the special paragraph and it’ll appear exactly where you want.

      As it only sniffs out HTML headings, there isn’t an automatic way to say ‘appear every time this exact block of text is displayed’. Other specific markup would not be common across other users imho.

      • Lars says:

        lol my fault^^

        i place the [toc] via functions.php after the second paragraph. it’s much easier instead of placing it in every article …

        add_filter( ‘the_content’, ‘toc’ );
        function toc( $content ) {
        if( !is_single() )
        return $content;

        $paragraphAfter = 2; //Enter paragraph number
        $content = explode ( “”, $content );
        $new_content = ”;
        for ( $i = 0; $i < count ( $content ); $i ++ ) {
        if ( $i == $paragraphAfter ) {
        $new_content .= '[toc]';
        }
        $new_content .= $content[$i] . "”;
        }
        return $new_content;
        }

  37. Pingback: WordPressの任意の記事にだけ目次をつける方法(Table of Contents使用)

  38. Hi, I just installed this plugin. I have a one page site (I stickied the page and made it appear on the home page of the site eg: http://www.mysite.com). The TOC Plus is NOT showing up on the page, even though I checked the “page” box in the options. Can you help please?

    • Mike T says:

      Go to the settings and open up the advanced options then enable “Include homepage”. It’s off by default.

  39. Hi, is there the ability to -/+ a certain Heading level? I have lots of H3s under my H2s which I would like to hide unless the user wants to expand it.

    • Mike T says:

      Nope. You’ll need to divide them into divs or sections and then add CSS to initially hide, then some jquery to enable toggling.

  40. Pingback: 7 Website Design Features That Will Increase Profits and Usability | ICMSEO

Comments are closed.