Archived topic
Header Element Conditional
3 replies · Started by Antar on October 24, 2019
Hello, All -
I'm sure I must have asked this before...
I want to create a page header displaying the featured image as a mast head. It works fine if an image is loaded but not when one is missing. To create the space for the image to appear it is necessary to add padding or set a min-height on the parent div. If the user fails to load a featured image on the page (for some reason) that space still remains.
Would it be possible to create a function that removes this empty space if no featured image is loaded?
Thanks,
Antar
Hi there,
Tom provides a snippet here that will remove the specific Header Element if no featured image is added:
https://generatepress.com/forums/topic/suppressing-hero-on-pages-without-feature-image/#post-980046
Bloody marvelous!
Thanks.
Glad we could be of help