Site logo

Archived topic

Excluding table of contents from some pages

8 replies · Started by CRAIG on July 17, 2021

Viewing posts 1–9 of 9

I use Lucky WP table of contents and there are a couple of options to insert the table of contents

1. Auto-insert - you can select post type (post,page,media,wptb tables) and also the position (before first heading,after first heading,after first block (paragraph or heading),top,bottom)

2. Shortcode

If I was using posts this would be perfect, as I could just select auto-insert, posts, after first block (paragraph or heading) and this would add my table of contents after the introduction paragraph exactly as I want it.

However, I am going to be using pages for my blog content and not posts (for various reasons - don't ask) and this presents a slight problem because on several of my pages I don't want a table of contents.

I was thinking one way to solve this might be to select the table of contents to appear on pages, but then have some way of blocking it from showing on the pages where it is not required e.g. home,contact,about,privacy etc.

I'm just not too sure of how to do that.

I do have some elements which are set up to perform actions on pages, excluding the "non-blog" ones referred to above. Perhaps I could add a little bit of code to one of those?

Thankful for any help

Hi there,

you could add the Shortcode they provide using a Hook Element, as you have with other elements and set the Display Rule Locations / Exclusions.

Hi David,

If I insert via shortcode I cannot set the position of the table of contents via the plugin so I'll need to do that in the hook.

Is there a way I can set the position of the shortcode to after the first paragraph in the hook settings?

I can see options like generate_after_entry_content but this doesn't have the desired effect.

Hi Craig,

Unfotruanly GP doesn't have Hooks inside content.

Since you are using the Lucky WP table plugin, have you tried reaching out to the plugin's support?
I think they'll be able to give you some code to exclude the function from some specific pages.

Hi Ying,

That's a shame

I need the table of contents to appear automatically on all future pages published except the excluded pages in the display rules

I'll reach out to their support and see what they say

We might be able to provide some CSS to hide the table on the front end, but if you want them to do not appear in the HTML at all, you'll have to reach out to the plugin support.

Let me know if you need further assistance :)

I just jumped onto the support forum for the plugin LuckyWP Table of Contents and it looks as though no-one is getting a response from the developer anymore

I will use another plugin for this, but I will see if I can find one which supports my requirements out of the box

***update - I have installed Easy Table of Contents***

This plugin seems to have a little bit more flexibility.

Still need help to move the TOC to after the first paragraph

I'll just manually insert for now

You could try adding it using the Ad inserter plugin - but i cannot say if they play well together.
If not manual insertion is the way to go.

This archived topic is closed to new replies.