Table of Contents Plus

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


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

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

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

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

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


Install / upgrade

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

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


The simplest approach

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

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

No shortcodes are needed.

Where’s my table of contents?

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

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

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

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

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

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

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

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

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


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

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

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

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

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

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

I want to ignore certain headings

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

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

Can I have the table of contents in the sidebar?

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

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

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

I would like to incorporate a sitemap

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

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

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

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

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

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


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

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

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

For developers

How do I customise my anchors?

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

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

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

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

Both parameters are optional:

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

These examples assume you are within “the loop”:

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

Versioning scheme

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

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

I love it, how can I show my appreciation?

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

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

Questions or suggestions?

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

1,136 thoughts on “Table of Contents Plus

  1. Hey
    I used TOC plugin on my website, but my links are not showing in the google search results. Here is the screenshot >>

    I am also unable to add that site map because I already added that in one of my page but google accepts xml : is this the reason my links are not visible ?

    P.S : I am already use Youst SEO sitemap and submitted that in google too

  2. Is there any way to enable the show/hide feature on the TOC sidebar widget? I can use it just fine with the shortcode in my posts, but I am wondering if there is a way to do it from the widget itself that I am somehow missing.

  3. I like the plugin, but its creating a duplicate title tag, or simply not removing the text from the tag it is replicating so i see the H2 tag twice back to back.. except the very first H2, it has an empty H2, then followed by the new H2 generated by the table of contents/plugin.. all the following tags display twice. Any suggestions?

  4. Ivan says:

    Thanks so much for this plugin. It is amazing!!!

    One question: How can you change the space between the TOC items? Headings of lower hierarchy show a very big space in reference to the next heading of bigger hierarchy. E.g.

    ← (this space I would like to remove)

    I really cannot find the option to change this. Thanks!


  5. sefi4 says:

    Hi, very good plugin congrats 🙂 The problem is my theme is using a sticky menu (stays on top when scrolling), and so when clicking a heading item in the Table Of Content, the heading itself is hidden by the sticky menu. Is there a way for me to tell “when going to a heading after clicking the Table Of Content, go like 30px above that item”.

    Hope you understood when I’m trying to say…


  6. atlant says:

    I ordered on the main to all pages open in a new tab.
    but the contents do not need to be opened in a new tab.
    How to make a table of contents could not be opened in a new tab?

    • atlant says:

      I ordered on the main to all pages open in a new tab.
      but the contents do not need to be opened in a new tab.
      How to make a table of contents could not be opened in a new tab?

  7. BenjaminGo says:

    Hello, thanks for the plugin! I have a question: Is it possible with css when you click on an menu point the h2 is colored ?

    • Mike T says:

      The easiest way to include your dictionary terms would be to make them heading 3s. That way they will automatically appear in the TOC list and under the letters. You can then use CSS to style them appropriately.

      There is no way to include custom predefined anchors.

  8. Hi. I just like to ask whether the table of content plus overrides the meta description set on a blog Post? It seems that there is an overriding circumstance that transpired on my post. Can you give an insight to this please?

    • Mike T says:

      This plugin executes on the_content filter which is normally ran when producing the content for the page. If the metadata plugin triggers the filter earlier than normal, then TOC+ (and any other plugin that operates in the same manner) would also fire.

  9. Ödel says:

    I love this plugin, I have used it in a couple of blogs and recommended it to several friends. But I just found on my new blog it will be difficult for me to continue using it. On my posts I am appending now a SiteOrigin Post Carousel at the end of my articles, and the title of the carousel plus the titles of my other articles are automatically added to the table of contents. If there was a way to tell TOC+ where it should start and end indexing content, so the unwanted headings wouldnt appear on the index, it would be amazing. It isn´t practical to add the titles of every new article (as they would appear on my post carousels) to the list of unwanted headings. So far I am doing it, but if there were other editors, it would be highly impractical

    • Mike T says:

      The simple fix for this would be to tell SiteOrigin Post Carousel to run after TOC+ runs when WordPress fires “the_content”. To do this, you’ll need to edit the Post Carousel PHP file, search for something like add_filter('the_content', xxx, number) and change the number to above 100. Alternatively, you can edit toc.php and tell it to run sooner than the Post Carousel. The number controls the queue, the higher the number, the later in the process it runs.

  10. Nikos says:

    Hello Mike,

    First of all I would like to thank you for creating such an awesome plugin and supporting it as well.

    My question is:
    How can we add an extra line spacing BEFORE and AFTER the H2 Headings or first level headings that come in TOC?

  11. veannaone says:

    This is such a great addition to my whole Wealthy Affiliate program of developing a navigable website. It has released a logjam in my mind of how to start getting content organized. Awesome. I’m really new to all of this and reading this comments section let’s me know how much I need to learn.

    I do have one question – I would like a button at the end of each TOC section to return to the beginning of the TOC. I have installed the plugin to return to the top of the page, but it goes to the very top of the page. I have started the TOC below my first paragraph and do not want to go past it. Is there functionality in your plugin to do this or do I need to add some code or install another plugin?

    Thanks again for this great addition to my whole online development experience.

    • Mike T says:

      Using the back to top plugin, are you able to provide a custom destination to return to? If so, tell it to go to ‘#toc_container’ which is the TOC box.

  12. I love your plug-in – thanks!

    An interesting little problem. My hosting service has enabled ‘Lets Encrypt’ so I am trying out switching sites to serve https pages. Looks like clearing the cache can be an issue – took a little while before all site images loaded as https. The site I am currently experimenting with has [toc] shortcode on selected pages/posts and on https it doesn’t work. Switching on auto insert it does work (where there isn’t the shortcode already). (I’ve checked on a test site that shortcodes work OK on a fresh install).

    Any ideas other than uninstalling and reinstalling the plug-in? (I’ve already de/activating.)

    Thanks again

    • Mike T says:

      To be honest – I don’t think TOC+ has anything to do with http or https. Nowhere in the code does it refer to a protocol. It uses the standard WordPress enqueue methods to pull in styles and javascript. If there is a lag issue, perhaps check enabled plugins that may be providing performance/caching improvements. I am running multiple sites over https and the transition was instant in all cases. In fact, both http and https versions were fine before redirection was enabled.

  13. Hey there! Thats a great Plugin! Just one Problem:

    It does not appaer on my Homepage. I cant understand why! It only works on posts and pages which are not the homepage…:(:(

    Please help….

    • Mike T says:

      It’s disabled for the homepage by default but you can enable it in Settings > TOC+ under the advanced section.

  14. J says:

    Hi there,

    Thanks for the nice plugin.
    My header menu floats when page is scrolled and therefor the anchors should be like 30px higher. Is this possible?

    • Mike T says:

      Yep, enable smooth scroll and adjust the height offset (if needed) under the advanced options. The default offset accounts for the WordPress admin bar.

  15. Hello Mike,

    Thank you for your great plugin, I have been using it for quite some time now and I am very happy with it.

    Only recently did I run into something that could be a bug or maybe just a limited option, you tell me.
    I have activated a home brew plugin that adds “Featured posts” to the end of “the_content”. Strange thing is that the widget doesn’t pick up the added headings, but the standard in-post-version does?

    Full screen = widget
    Scale browser below 700px = shows standard TOC

    Could you elaborate on this? Thanks in advance!

  16. Pingback: Plugin para crear una tabla de contenidos en WordPress

  17. Pingback: چگونه برای برگه ها و پستهای سایت، (به صورت اتوماتیک) فهرست مطالب تهیه کنیم - وبی لب WebbyLab

  18. It won’t show the TOC on posts on the main page (where multiple posts show), though it shows for each individual post (upon going to that post’s page). Is it possible to show it on the main page, where multiple posts are shown?

    • Mike T says:

      It’s disabled for the homepage but you can enable it in the advanced options in Settings > TOC+. Disabled because it’s not intended to be run when there is a listing of articles (you may get duplicate anchors).

  19. Hi Mike,

    My site is Thrive Best dot com.

    The TOC does not show up in the content but it works in the sidebar.

    I have a friend who has the same theme as mine (Pin Blue) and her TOC works both in content and sidebar.

    Any solution for me?


  20. Wow…just what i needed for my lengthy FAQ~ But is there s setting that when someone links to a line in the TOC, when it goes to that content they have a link to return to the TOC without having to scroll a few pages to get back?…many thanks

  21. Hi. I love your plugin! nice work, very usefull.

    I use toc_get_index() to display the toc in a navbar submenu,

    but the anchors are not provided in post heading (no ‘span id=”…”>…</span')

    this is because I de-activate the toc for post (I don't want duplicate it in post content or in a widget sidebar)

    How can I force the creation of anchors in content?
    There is a filter to apply to the_content()?


  22. Aleksandar Borisov says:

    Hi Mike T, Thanks for the great plugin, I have a website called and after updating the main theme to Schema 3.0, the top offset is no longer respected by it. I need to have 70px for desktop menu and 45px for my mobile menu.

  23. rsr2001 says:

    Mike thank you for your altruistic and wonderful support of TOC+. Do you accept donations to help you support your work… coffee gift cards ….

  24. Pingback: Table of Contents Plus 1601 | dublue

  25. Hi Mike, thank you for this great and easy to use plugin!
    I am using the plugin Aesop Story Telling Engine and I want the TOC of a page/post in a sidebar only. Unfortunately for the sidebar TOC the shortcodes are not yet processed – so the Aesop Chapters (which are actually shortcodes creating h2 HTML) do not show up in the TOC. A TOC at the end of the page with shortcode [toc] shows perfectly all Aesop chapters, too.
    Any idea, how I could get the complete toc into the sidebar?
    Thanks for any hints!!!

    • Mike T says:

      No idea – do you have a plugin that tries to link up related articles for you? It’s not appearing in the TOC because either the “related” heading is not a HTML heading or the related plugin runs after TOC+.

  26. Pingback: JanPaul999 on "[Plugin: Table of Contents Plus] Scroll offset not working on my site" * Best Wordpress Themes - Reviews

  27. Hi Mike, first of all, great plugin. Thanks. Been using it for a few years and my visitors love it.

    That said, I’m having a problem now after switching to a new theme with a consistent top menu…

    I have set “Smooth scroll top offset” to 50px but it doesn’t do anything – the setting is not working for me.

    Can you please have a quick to see what it could be?

    You can see one of my TOC+’s here:

    Thanks a ton,


  28. Hi Mike,

    Really love the Contents plugin, its made my pages look a lot neater.
    I am having a small problem with one of my pages

    The layout is with little boxes and I want to centre the Table of Contents at the top of the page but it won’t let me in the backend composer in wordpress. Is there another way i can centre the Contents on a page?


  29. I am finding an issue in Mobile pages. When I click a tag from TOC menu it jumps to the right header but at the same time it hides all contents above it.
    Say I clicked tag 1.0.5, it jumps to the 5th header correctly but hides all contents above it i.e. 1.0.1 to 1.0.4.
    I tried on android devices and different browsers… same results.

    Please help.

  30. Hi, thanks for your great plugin!
    One thing that did not work out for me: When using the table in sidebars only, I can use the general settings (TOC+) to change the minimum of headings necessary to create a table. So far, so good. But I cannot switch off or change the title above the table (by default:”Contents”). It would be great if you could change this with the next update or so.
    Best, Dirk

  31. Martin says:

    Hi, very nice plugin,

    but the plugin always delete settings if I want to save them.

    What can I do?

    Best Regards

    • Mike T says:

      Sorry but it’s never done that for me? You’ll need to enable your browser’s debugging console to see if there are any issues that is preventing it from saving (eg from other plugins or the theme itself).

  32. Max says:

    Hi Mike, Awesome plugin thanks so much for this. I am using it to show all the posts on my site and i usually post twice a week, as i have been doing this for awhile the list has become very long under each main heading

    is there a way to show the alphabetic characters and only expand to show the posts withing it only once clicked

    • Mike T says:

      sitemap_posts adds a surrounding div around each section of letters with hooks that could be used to apply this affect, so with some javascript and CSS, you may be able to do it? It is a good suggestion though.

      Here is the structure:


  33. Hi,
    It is really good plugin for my site.
    Can I change the title in the TOC without changing the title of the actual contents.
    I want to make the title in the TOC a little bit shorter.

  34. Nice one. Have been using it from long. List of post can it come like the list of pages instead of grouping in alphabetical order.


  35. Pingback: test jump link

    • Mike T says:

      Change the width to 95% and it shouldn’t overlap from the content’s boundaries. You can experiment + or – from there.

  36. Pav says:

    Hey there Mike,
    Love the plugin.
    I am doing an experiment, trying to make it work with a slider (paginated pages).
    My results so far
    Do you have any ideas how to make it work with pages like this?
    Thanks again, this is one of the best supported free plugins I have ever seen.

    • Mike T says:

      It will probably have something to do with smooth scroll so first turn that off to see if it works. If you want smooth scrolling, then it would need to trigger the slide action of the sliding library you’re using.

  37. Pingback: Table of Contents Plus: A Great WP Plugin for More Traffic (Free) — FAT Stacks Entrepreneur

  38. Hello; Great plugin !! verrry happy with it..

    My question.:

    Is it possible to create three TOC+ on one page ??
    So if….how to do that and what is the procedure to create three TOC+ on one page.



  39. Hello Mike, thank you for your plugin, it rocks. And I mean it!
    I have a problem:

    1) On posts where I activated TOC+ all the H1,H2,x text went from black to gray. Nothing changed on the pages without TOC+. How to change it and keep TOC+?

    Thank you. Website is amazingtelescopes dot com, check out any post, not page.

    • Mike T says:

      This plugin encapsulates the headings in html span tags. So if there are visual differences, then your theme has different styles for headings with span tags. I checked your site and this is the case for you, see line 249 of

      .entry h1 span, .entry h2 span, .entry h3 span, .entry h4 span, .entry h5 span, .entry h6 span {
      color: #BBB;

      To change it, see if you can insert your own custom CSS with something like:

      .entry h1 span, .entry h2 span, .entry h3 span, .entry h4 span, .entry h5 span, .entry h6 span {
      color: #444 !important;

  40. Pingback: Test Matrix Table of Contents - Critical to Success

  41. Hello, to help Google Analytics for referencing, Google let us activate the “Console” to check how google see our website. In the “Sitemap” section, we locate our “sitemap” page including only the TOC shortcode (, but Google doesn’t recognize it as a sitemap, but as an HTML page. Is there any specific link for TOC sitemap to tell Google ?

  42. We’d like to style the TOC… like implementing a decimal and some extra spaces after the number (“1. First Section”), or bold the first level, etc. How might we do this?

    • Mike T says:

      You can do all that with some custom CSS. Just inspect the table of contents and you’ll see some selectors you can use to add your styles to. Examples:

      For the dot after the number:

      .toc_number::after {
      content: '. ';

      For the bolded first level headings:

      .toc_list li ul {
      font-weight: normal;
      .toc_list > li {
      font-weight: bold;

  43. VS says:

    The plugin created a ToC on a page that we did not want it, and despite deleting hte plugin we cannot remove the ToC, can you help? <link removed>

    • Mike T says:

      I don’t see any TOC on the page you provided. I didn’t see any signatures of this plugin in the source either.

    • Mike T says:

      I haven’t tested this plugin with any multilingual plugins so I’m not sure if it would behave as intended, however if each of your different languages were a different site or install, then it should be fine. That said, perhaps the multilingual plugin may do it for you?

Comments are closed.