I have the following code at the start of my single.php loop that displays the post featured image as a background.
<?php $featured_background = wp_get_attachment_image_src( get_post_thumbnail_id( get_the_ID() ), 'full' ); ?>
<div class="parallax" id="parallax1" style="background: url(<?php echo $featured_background['0'];?>) !important; background-position: 50% 50% !important; background-repeat: no-repeat !important; background-size: cover !important; background-attachment: fixed !important;" data-stellar-background-ratio=".5">
<div class="parallax-content">
Some content
</div>
</div>
I've set .parallax to be 600px high in the stylesheet.
Of course this poses a problem for posts that don't have a featured image.
It seems then that I need a conditional statement that only displays the code above if the post has a thumbnail.
I've looked at the wordpress codex, but am unsure how to apply the teachings there to my case. It also looks like they'd be a lot of use of the echo command due to all the HTML.
I think I understand the first part of the statement which will be something like:
<?php
if ( has_post_thumbnail() ) {
echo'my html code as above'
}
else {
just get on with rendering the rest of the page
}
?>
But then I don't understand how to tell it to just get on with rendering the page in the else statement.