I’m stuck right now trying to figure out why my featured image is not showing as my header background image.
Here is what i have so far:
<?php
function featured_img_url() {
if (has_post_thumbnail() and is_singular()) {
$gs_thumbnail_url = get_the_post_thumbnail_url( get_post(), 'thumbnail' );
echo 'background-image: url(' . $gs_thumbnail_url . '); background-repeat:no-repeat; background-size:contain;';
}
}
?>
<div class="main-wrapper">
<div class="featured-image" style="<?php featured_img_url();?>">
<header class="page-title theme-bg-light py-5">
<h1 class="heading"><?php the_title(); ?></h1>
<!--<img class="header-img" src="wp-content/themes/gary-schoeniger-llc/assets/images/gs-new-book.jpeg" alt="header-image">-->
</header>
</div>
In my stylesheet I have this:
.featured-image {
background-repeat: no-repeat;
background-position: center;
background-size: contain;
}
I tried multiple varieties of how to display it and they still don’t display. Looking at the Developer Tools on the site to check to see if the values are there, they’re there but won’t show.