TOC Shortcode

Like the Wikilink shortcode, the TOC shortcode also has an editor button for convenience. When you click on the TOC button you also get a popup. There are three options when using the TOC button.
The first option is to not make any selections and just insert the shortcode without any options selected. If you do this then you will get the TOC page that you previously created. Note that you have to have a published TOC page in order for it to show in the front end.

The second option shows the pages for a Wiki Category. If a “Category” is chosen then that will override the insertion of the TOC content and will instead insert a list of the wiki articles assigned to that category. The category list can be ordered by article title or by article creation date. Title is the default. If no category is chosen the “Order” parameter is ignored.
The screenshot on the left shows the TOC popup. Although I’ve discussed the buttons for inserting shortcodes, WordPress allows you to also type them in manually if you prefer.
Here are some examples of the TOC shortcode. The first one is the default and the second one is using the category option:
[yadawikitoc show_toc="true"] [yadawikitoc show_toc="true" category="Yada Wiki" order="title"]
Here is the output from the category TOC shortcode above. Note that it is only styled as an un-ordered list. If you want additional styling then you can surround the shortcode in the editor with the styling you want. A good use for the category option is if you wanted to create an alphabetical glossary:
- Acknowledgements
- Article Index
- Categories and Tags
- CSS Classes
- Frequently Asked Questions
- Is the plugin compatible with Gutenberg?
- Links and Shortcodes
- Plugin Overview
- Requirements and Installation
- Settings
- Sidebar Widget
- TOC Page
- TOC Shortcode
- Using Multiple Shortcodes
- Widget Usage
- WikiLink Optional Parameter
- WikiLink Shortcode
The third option is to output an index. You can output an index of Wiki Pages or an index of categories. If you look on the right sidebar at the Wiki Table of Contents, you see an “Article Index” link. That page uses the pages index option.
If you have used wiki categories extensively to organize your wiki then the category index option might be useful. When you select to output an index of categories, you can choose either a single category or all categories. Empty categories, with no wiki pages or child categories assigned, are excluded. Also, while in WordPress you can create deep category trees, the index of a category or all categories only goes down to one level of child categories.
There is the option to sort the category output by slug. Some people may have categories that are people’s names, such as book authors. The alternate ability to sort by slug gives some flexibility for custom sorting if, for example, you use the author’s last name for the slug.