Archived topic
Page Header Featured Image Template Tag
9 replies · Started by Chad on May 4, 2018
Hi, is there a template tag for using the featured image within the HTML content section?
Something like {{post_thumbnail}} or {{post_image}}...
I need to use the featured image as an image in the content rather than just the background. I could create a custom field but would prefer to avoid that is possible.
Thank you!
Oh, wanted to add... I need it to use the featured image of the page the page header is being used on -- not the featured image on the page header itself -- hope that makes sense. :)
Doh, found it.
{{custom_field._thumbnail_id}}
:)
I guess one follow-up question.
Do page header {{custom_field}} tags work with ACF?
Nevermind, I found out it does.
A thread all to myself! ;)
Glad you got it all working! This thread will likely be very helpful to others :)
Thanks!
Hi Tom. Follow-up question.
Is there a way to target specific image sizes with {{custom_field._thumbnail_id}}?
Thanks!
There is!
Try this:
add_filter( 'generate_page_header_thumbnail_id_size', 'tu_adjust_page_header_featured_image' );
function tu_adjust_page_header_featured_image() {
return 'full';
}
Hi Tom, I'm not a coder so beware!
I follow everything up to why you provided the "add_filter" php??? code snippet, but where do I add this code? Do I use the Elements functionality? Or do I need to install the "Code Snippets" plugin?
Just a nudge in the right direction and I'll probably "get it." Thanks!
Hi there,
that code is PHP - this article explains the options:
https://docs.generatepress.com/article/adding-php/
TLDR: Code Snippets is the method we recommend if you're not using a Child Theme