-
Cheezballz
I’m working with the Wellbeing template and I cannot figure out how to get the page hero to show the featured image instead of a static background image. I used to know, but the settings have changed.
For the ‘Page Hero – Pages’ element, I tried putting
{{featured_image key:url}}into the Inline Background Image field for the main Section container but it’s not working like it does for the Section container in the ‘Template – Single Post’ element. Why is this?I did add a featured image to the About page, and it’s displaying below the header.
-
Hi there,
It should work.
Can you provide an admin login and let me know which element it is?
Your site is in maintenance mode. I can not see any content.
Let me know 🙂
-
Cheezballz
Here you go.
-
You have a static image set as a background image, it overrides the dynamic bg image:
https://app.screencast.com/rTgbbe03gO69e -
Cheezballz
I see. How would I make a ‘default’ bg image for pages that don’t have a Featured Image set?
-
Try this, replace
100with the actual fallback image ID.function add_fallback_featured_image($value, $post_id, $meta_key, $single) { // Check if we're retrieving the post thumbnail if ($meta_key === '_thumbnail_id' && !$value) { // Set your fallback featured image ID return '100'; // Return fallback ID if no thumbnail is set } // Return the original value if it's already set return $value; } // Hook into get_post_metadata for the _thumbnail_id meta key add_filter('get_post_metadata', 'add_fallback_featured_image', 10, 4); -
Cheezballz
Thanks Ying. Will that create a fallback for place there’s an image? How would I make it specific to an element?
-
This code create a fallback featured image for all posts and pages.
How would I make it specific to an element?
so you only want it to apply to pages? If so, you can add a
is_page()condition to the code.function add_fallback_featured_image($value, $post_id, $meta_key, $single) { // Check if we're retrieving the post thumbnail if ($meta_key === '_thumbnail_id' && !$value && is_page()) { // Set your fallback featured image ID return '100'; // Return fallback ID if no thumbnail is set } // Return the original value if it's already set return $value; } // Hook into get_post_metadata for the _thumbnail_id meta key add_filter('get_post_metadata', 'add_fallback_featured_image', 10, 4); -
Cheezballz
Got it, thank you!
-
You are welcome 🙂
- You must be logged in to reply to this topic.