I'm trying to create a function that checks for the existence of a post_thumbnail()
for a post in Wordpress
and sets an element's background image appropriately. Here's what I've tried:
<div class="header-cover-image" style="background-image: url(
<?php if ( has_post_thumbnail() ) {
the_post_thumbnail('full');
} else { echo get_template_directory_uri() . '/assets/img/article-overlay-1.jpg' }?>
">
</div>
This currently crashes/causes the page to render nothing at all. I'm so confused about when and where to use quotation marks when using PHP within HTML markup!
Any ideas how I can make this work?