Support

Account

Home Forums Front-end Issues true false won't show unless ticked in order

Helping

true false won't show unless ticked in order

  • Hi there

    I am using true false advanced custom fields on http://mellonsgroup.com/product/hyundai-i10/ – in the features box. When our client adds a car, he uses a check box when adding a product in admin and ticks which features the car has. But the features only display if all selected in order.

    For example, when he goes to add product in admin, the features display in following order:

    DAB RADIO
    bluetooth
    air con
    sat nav
    heated seats

    So if he ticks
    DAB RADIO
    bluetooth
    air con

    then they all display fine on product front end page but if he selects only the bottom two options, then no features will display fronted of product page? code on product template page is:

    <h1 style=”font-size:18px; color:#1e238b;”> FEATURES</h1>

    <span id=”one”><?php if( get_field(‘dab_radio’) ): ?>
    <?php the_field(‘dab_radio’) ?></span><div id=”button”>DAB Radio</div>
    <?php endif ?>

    <span id=”one”><?php if( get_field(‘bluetooth’) ): ?>
    <?php the_field(‘bluetooth’) ?></span><div id=”button”>bluetooth</div>
    <?php endif ?>

    <span id=”one”><?php if( get_field(‘air_con’) ): ?>
    <?php the_field(‘air_con’) ?></span><div id=”button”>Air conditioning</div>
    <?php endif ?>

    <span id=”one”><?php if( get_field(‘sat_nav’) ): ?>
    <?php the_field(‘sat_nav’) ?></span><div id=”button”>Sat Nav</div>
    <?php endif ?>

    <span id=”one”><?php if( get_field(‘heated_seats’) ): ?>
    <?php the_field(‘heated_seats’) ?></span><div id=”button”>Heated Seats</div>
    <?php endif ?>

    thanks in advance

  • You missplaced the span opening tags before the questions if each field is present. Also there should always be one identical id at the current page, so change the parameter of the ids. (also change id="button" to class="button")

    <h1 style="font-size:18px; color:#1e238b;"> FEATURES</h1>
    
    <?php if( get_field('dab_radio') ): ?>
    <span id="one"><?php the_field('dab_radio') ?></span><div class="button">DAB Radio</div>
    <?php endif ?>
    
    <?php if( get_field('bluetooth') ): ?>
    <span id="two"><?php the_field('bluetooth') ?></span><div class="button">bluetooth</div>
    <?php endif ?>
    
    <?php if( get_field('air_con') ): ?>
    <span id="three"><?php the_field('air_con') ?></span><div class="button">Air conditioning</div>
    <?php endif ?>
    
    <?php if( get_field('sat_nav') ): ?>
    <span id="four"><?php the_field('sat_nav') ?></span><div class="button">Sat Nav</div>
    <?php endif ?>
    
    <?php if( get_field('heated_seats') ): ?>
    <span id="five"><?php the_field('heated_seats') ?></span><div class="button">Heated Seats</div>
    <?php endif ?>
Viewing 2 posts - 1 through 2 (of 2 total)

The topic ‘true false won't show unless ticked in order’ is closed to new replies.