Table of contents

I think adding a TOC would help the theme sell more and I think a lot of users would appreciate it.

2 Likes

Hi,
Just a note that GenerateBlocks is actually a plugin and not so much a theme.
Edit: completely missed the title and implied terms of service instead of Table of Contents. My bad.

1 Like

I’ve literally just popped on to ask if there is a table of contents block! I think you’ve just answered my question!

I’d love this too — save me using a separate plug-in. Please can I also ask for this feature to be included?

1 Like

A question: How would you like your Table of Content to act and look like? Does it include dynamic content or does it need to be more a sort of styled library asset?

Here is a link to a javascript solution.

You can build it as a local template or paste it as HTML blocks (not ideal as the js gets loaded in the content). A different approach can be with ACF pro or similar to create a custom block for this or add the js to a child theme.

Hello Bianca! I just want something really basic and clean. I’m using a plug-in at the moment called Easy Table of Contents — it’s really simple and works fairly well. You can see it working on my blog — Sanctuary Spa Products Review by The Twinkle Diaries

Ultimately I’d love this feature as part of GP — I think the less third party plugins, the better!!

Thanks for clarifying. My own two cents:
I can definitely follow the vision of not wanting to install too much plugins. Especially when most plugins (by different authors) add another Top level menu item. Makes a WordPress website harder to maintain and messy. I get that.

However on the other hand, I personally think a plugin like GenerateBlocks has to be careful to not to become too bloated by integrating too much function (javascript, php etc). Adding a CSS styled TOC element (not dynamic) to the Template Library would be nice and useful, I think.

It’s a tough choice for what is best for some type of users and what’s best for the design of the plugin.

I basically have 3 approaches that I often choose between. However I understand this is not for everyone.

  1. I use GeneratePress Premium as a theme (with child theme), where I can create elements and add javascript on a per page basis.
  2. I use a plugin like Advanced Custom Fields Pro where you can relatively easy build your own blocks. For me ACF pro replaces a lot of extra plugins. But some coding skill may be required.
  3. Genesis Custom Blocks. Like ACF Pro (but there is a free version that lets you build blocks) you can build your own blocks.

EDIT: I just visited your site and see you do use GeneratePress Premium. If you want to get rid of the TOC plugin, you can add the code I mentioned above in an element. Steps:

  1. Create a ‘Hook’ element and name it.
  2. Then select the the generate_before_footer hook
  3. Assign the code to the pages where you want the TOC to appear upon.
  4. Paste the code I mentioned above placed between <script>and </script>
    (It fails to paste the complete code here in my reply so I placed it here to copy paste )
  5. Adding the table of contents you either paste the < div d=“ToC”> in the post directly or create a local template for it.

If you don’t want the text Table of Contents included You can leave out the bit after // add a header and before //Create a list for the ToC entries.