Site logo

Archived topic

Is there a way I can call an Element 'after-featured-image' ?

7 replies · Started by Anne on September 28, 2020

Viewing posts 1–8 of 8

Basically i want a disclosure at the top of the 'article content' , but below the title, meta info, and featured image - But I'm not seeing the option. Is there a way to make a custom hook for this?

I added it to each post manually but I want to remove that and just have it added automatically via Element here:
https://prnt.sc/upo1zv

Thanks

Hi,

You can use generate_after_entry_header hook.

I think you'll appreciate having this. https://docs.generatepress.com/article/hooks-visual-guide/

It's basically a map of hooks. :)

You can create your disclosure block using the Block Element and hook it to generate_after_entry_header. :D

See, I was 95% sure it was going to be generate_after_entry_header but, it did not show up there. I just tried it again and it puts it below the tags i added at the top: https://prnt.sc/upobcg

I'm wondering if it has something to do with the php snippet i added for adding the tags below the author:

add_filter( 'generate_header_entry_meta_items', function( $items ) {
    if ( is_single() ) {
        $items = array(
            'author',
            'tags',
        );
    } return $items;
} );

Adding PHP snippets shouldn't affect Block Elements.

Can you check again? It should be on the "Hooks" dropdown. You can also type it in.

Here's where you can find it.
https://share.getcloudapp.com/kpuwkLBq

You can leave the site details on the Private Information text area if you need help in checking things.

I have the right hook selected already:
https://prnt.sc/uporm6

I've created some login details for you below. Btw when you login, remember i have added a disclosure manually to every post. That's in the correct position, but the hook is not.

Oh I forgot to mention its correlation to Featured Image display location settings for posts on Appearance > Customize > Layout > Blog. My bad.

When the Location setting for Featured Image is set to "Below title", the featured image is placed after the entry header as opposed "Above title" where the featured image is placed inside the entry header.

You pretty much have both the featured image and the block header hooked to generate_after_entry_header.

Knowing this, we set the Priority for our Block Element to a value higher than 10 (10 being the priority set to featured image) so it appears after the featured image.
https://share.getcloudapp.com/8Lur47we

ah ha! priority 11 worked.

Solved thank you!

Nice one.

No problem.:)

This archived topic is closed to new replies.