Site logo

Archived topic

How Do I Position Block Hook After Feature Image?

16 replies · Started by RJ on January 31, 2022

Viewing posts 1–15 of 17

Hey there - is there a way to have my block hook appear:

1. after my feature image?

2. after my table of contents?

Here's an example page.

TIA

Hi Robin,

Both of your inquiries should be possible. The hook you’ll be using to display your custom block under the Featured image or under the table of contents would depend on how you’re adding these two.

For instance, in my test website, I’m adding the Featured Image through the Customizer settings.

See this for reference: https://share.getcloudapp.com/o0uZXADk

Correspondingly, looking at the Hooks Visual guide (https://docs.generatepress.com/article/hooks-visual-guide/), I can simply choose after_entry_header as the Hook name and set the Priority to something higher than the default which is 10 to display my block element under the featured image: https://share.getcloudapp.com/7KuqkN06

Moreover, if you’re adding these two through Block Elements as well, you can try using the same hook name used, and then set a higher priority to push the new custom block element below.

If you’ll need further assistance regarding this, may I know how you’re adding the Featured image and the table of contents in your website so I can recommend a hook which would suit best for your preference?

Hope to hear from you soon! :)

Hi Fernando,

Thanks for that. I've created a screen recording of what I have done using your suggestions. I still need to try and make the gold/red box appear under the Table of Contents, but hopefully, everything is explained in the screen recording.

Watch the screen recording here.

TIA

I tried accessing the link to the screen recording, however, I am unable to do so.

For reference, this is what I see: https://share.getcloudapp.com/geudyDNX

Can you try sending a link of the screen recording again? Thank you! :)

Hi there,

The Easy Table of Contents plugin auto inserts the table into your post content, which makes it impossible to move it between two blocks in the block element. Instead we need to add the ToC in the Block element:

1. In the ToC plugin settings disable the Auto Insert.
2. Edit the Element containing your featured image and gold box:
2.1 Add a Shortcode block above the gold box HTML.
2.2 Add the ToC plugins shortcode: [ez-toc]

Many thanks, David. Much appreciated. That worked. Awesome!

Robin

Hmmm.... thats super weird, can you temporarily disable autoptimize ( and any other cache / optimization plugins if any )

I disabled pretty much every plugin, see here.

The links still don't work.

Any ideas?

So the easy ToC shortcode no longer likes being hooked into places. Its adding the correct IDs to each of the headings but the Links it creates are incorrect. They all start with a Capital eg #Link instead of #link and hyphens are replaced by underscores.... eg, #The_link instead of #the-link

Which is completely baffling and something the plugin author would need to address.

OK, I'll look into using a different plugin and get back to you.

Odd one as it used to work - i wonder if the latest version of WP has messed with its workings.
I did look at alternative methods such as filtering the content to add that block in after the auto inserted ToC but that has a completely different set of problems.

The one thing i could get to work was to Hook inside the ToC - but it would be inside the grey container... let me know if thats an option.

Thanks, David. I've disabled it and installed ToC+. They say this:

If you would like to fully customise the position of the table of contents, you can use the [toc] shortcode by placing it at the desired position of your post, page or custom post type. This method allows you to generate the table of contents despite having auto insertion disabled for its content type. Please visit the help tab for further information about this shortcode.

I tried it using the method you mentioned earlier, but it didn't work. Maybe the latest WP has broken the ability as you mentioned for lots of plugins.

ATM, the location is good enough, just not how I would really like it to look.

If you have any ideas, I am all ears. Here are the ToC+ Help files.

Cheers.

I think both those plugins are built on the same code. Bit of a head scratcher. Whatever scripts its using doesn't recognise the ToC is present on the page when added by a hook.
If you leave it in the Block Hook and also enable the Auto function in the plugin settings so there are two on the page then they both work. So not ideal but you could do that and we could hide one with CSS....

This archived topic is closed to new replies.