Support

Account

Home Forums General Issues If / Else for header image

Helping

If / Else for header image

  • I’m trying to create a field to display a header image, which if it isn’t filled in will display a background colour instead… this is the code i’ve put in but I get a WP error message instead:

    <?php if ( get_field( ‘header_image’ ) ) { ?>

    <header class=”content-header content-header-image” style=”margin-bottom: 60px”>
    <div class=”wrap” data-parallax=”scroll” style=”background-image: url(<?php the_field( ‘header_image’ ); ?>);background-size: cover; background-position: top center;”>
    <h1 style=”font-size: 68px; font-weight: 600;color: #ffffff”>Insights</h1>
    </div>
    <?php } ?>
    </header>

    <?php else: ?>

    <header class=”content-header content-header-image” style=”margin-bottom: 60px”>
    <div class=”wrap” data-parallax=”scroll” style=”background-color: #009fe3″>
    <h1 style=”font-size: 68px; font-weight: 600;color: #ffffff”>Insights</h1>
    </div>
    <?php } ?>
    </header>
    <?php endif; ?>

    Can anyone help?

  • Hey man,

    Can you send the error message?

Viewing 2 posts - 1 through 2 (of 2 total)

The topic ‘If / Else for header image’ is closed to new replies.