Site logo

[Resolved] How Do I Position Block Hook After Feature Image?

Home Forums Support [Resolved] How Do I Position Block Hook After Feature Image?

Home Forums Support How Do I Position Block Hook After Feature Image?

Viewing 15 posts - 1 through 15 (of 17 total)
  • Author
    Posts
  • #2100871
    RJ

    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

    #2100953
    Fernando
    Customer Support

    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! 🙂

    #2101036
    RJ

    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

    #2101054
    Fernando
    Customer Support

    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! 🙂

    #2101136
    RJ
    #2101184
    David
    Staff
    Customer Support

    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]

    #2101324
    RJ

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

    Robin

    #2101329
    RJ

    Actually, I have just noticed that the links in the Table of Content do not work now.

    See: https://www.eatweeds.co.uk/alexanders-smyrnium-olusatrum

    Any ideas what to do?

    #2101353
    David
    Staff
    Customer Support

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

    #2101382
    RJ

    I disabled pretty much every plugin, see here.

    The links still don’t work.

    Any ideas?

    #2101618
    David
    Staff
    Customer Support

    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.

    #2101624
    RJ

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

    #2101634
    David
    Staff
    Customer Support

    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.

    #2101666
    RJ

    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.

    #2102436
    David
    Staff
    Customer Support

    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….

Viewing 15 posts - 1 through 15 (of 17 total)
  • You must be logged in to reply to this topic.