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?

    • vverner

    • August 14, 2019 at 10:59 pm

    Hey man,

    Can you send the error message?

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

You must be logged in to reply to this topic.

We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Cookie Policy. If you continue to use this site, you consent to our use of cookies.