Site logo

Archived topic

Can I add the Featured Image inside

3 replies · Started by Michael on December 10, 2020

Viewing posts 1–4 of 4

I need to add the Featured Image to the <header class="entry-header> tag.

This <header> tag currently contains the entry title (as an H1) and then a custom field for a subtitle. I'd like to get the Featured Image to appear underneath the subtitle.

I can find a "generate_after_entry_header" hook, but this doesn't work as it's "after" and not "inside at end" ;-)

Do I need to create template files or is there a way to achieve this within GeneratePress options/settings?

Many thanks

(Site is not online yet)

Hi,

There's no hook for "inside" the entry header unfortunately.

You can check these files and see that there's none:
https://github.com/tomusborne/generatepress/blob/master/content.php
https://github.com/tomusborne/generatepress/blob/master/content-link.php
https://github.com/tomusborne/generatepress/blob/master/content-single.php
https://github.com/tomusborne/generatepress/blob/master/content-page.php

https://docs.generatepress.com/article/hooks-visual-guide/

Do I need to create template files or is there a way to achieve this within GeneratePress options/settings?

Yes you'll have to create a child theme and template to achieve this.

Thanks for those links - I found an answer which I think will do the job and won't need a template: generate_after_entry_title.

BTW, I had been looking at the Hooks Visual Guide reference. If I'm reading it correctly, I think on the 'static page' image it doesn't show generate_before_page_title or generate_after_page_title. But the https://github.com/tomusborne/generatepress/blob/master/content-page.php file shows that they are there - maybe a documentation bug?

Thanks again - you've helped me get back on track!

Thanks for those links – I found an answer which I think will do the job and won’t need a template: generate_after_entry_title.

Oh lol, that's right. I read entry_header but thought of something else. My bad.

But yes, that may work but that's for posts. If you want to use something similar on static pages, use generate_before_page_title.

But the https://github.com/tomusborne/generatepress/blob/master/content-page.php file shows that they are there – maybe a documentation bug?

Documentation images are a bit outdated. We're actually in the process of of updating it for 3.0.2 as we've added more filters and hooks for flexbox but most of the things there are 95% the same.

Thanks again – you’ve helped me get back on track!

No problem. Glad to be of any help. :D

This archived topic is closed to new replies.