Support

Account

Home Forums General Issues Custom Field Not Displaying

Unread

Custom Field Not Displaying

  • Greetings:

    I’ve created three different custom fields. All custom fields are set up the same way; two serve a similar purpose as background images in a blank div container, but one is to be used as a background for a widget block. It is the widget background one that is not working. The other custom fields work fine, as they are associated to ‘Pages’. But I’m trying to get the third one (event_image) to associate to a Widget Block.

    Settings:
    Field Label: Event Image
    Field Name: event_image
    Field Type: Image
    Rules: Logged in User Type = Administrator

    Code:
    <?php if( get_field( “home_background_image” ) ) {
    echo ‘<div class=”homebanner”></div>’;
    } elseif ( get_field( “background_image” ) ) {
    echo ‘<div class=”banner”></div>’;
    } elseif ( get_field( “event_image” ) ) {
    echo ‘<div class=”anncbanner”></div>’;
    } else {
    echo ‘<div id=”content” class=”site-content noban”>’;
    }
    ?>

    CSS code:
    .anncbanner {
    background-image: url(‘<?php the_field(‘event_image’); ?>’);
    background-size: cover;
    background-repeat: no-repeat !important;
    background-position: center center;
    height: 451px!important
    }

    <div class=”anncbanner”> does appear in the code with the widget block content in the container, but there is no image. I’m rather confused. How can I get the image to display as a widget background?

Viewing 1 post (of 1 total)

The topic ‘Custom Field Not Displaying’ is closed to new replies.