I'm trying to make my feature image (hero image) on WordPress to be dynamic (depends on the page). I have the following code to do it.
<?php if( has_post_thumbnail() ) { // check for feature image ?>
<section class="feature-image" style="background: url('<?php echo $thumbnail_url; ?>') no-repeat; background-size: cover;" data-type="background" data-speed="2">
<h1 class="page-title"><?php the_title(); ?></h1>
</section>
<?php } elseif ( is_page('faqs') ) { // fallback image ?>
<section class="feature-image feature-image-faqs" data-type="background" data-speed="2">
<h1 class="page-title"><?php the_title(); ?></h1>
</section>
<?php } ?>
<?php else { // fallback image ?>
<section class="feature-image feature-image-default" data-type="background" data-speed="2">
<h1 class="page-title"><?php the_title(); ?></h1>
</section>
<?php } ?>
However, an error is prompted on this line:
<?php else { // fallback image ?>
The error goes like this:
syntax error, unexpected T_ELSE in
What is wrong with my code?