Support

Account

Home Forums General Issues Hide div on front end if ACF input is empty

Helping

Hide div on front end if ACF input is empty

  • Hi all,

    I am making a content template for an events page using the Impreza WordPress theme which comes with Advanced Custom Fields as an add-on. The template is being built using Visual Composer.

    I have a div with the ID ‘#show-info-wrapper’ which holds content pulled through by a custom field named ‘show_info’.

    On some event entries, the custom field may not be filled out, but the div will still show although it’s empty.

    I have seen some answers on here in which the if the statement is wrapped around the div itself e.g:

    if (get_field(‘cashback’, $term)) {
    ?>
    <div class=”cashback-css”>
    <strong”><i class=”money icon”></i>Cashback: <?php the_field(‘cashback’, $term); ?>
    <p class=”cbquery” data-toggle=”popover” title=”What is Cashback?” data-content=”Cashback from ElkeesDeals is real money that is added to your ElkeesDeals”>(What’s this?)</p>
    </div>
    <?php

    However, the above example will not work for me as the template is with a page builder, and the code will need to be set in the theme options.

    Is there any if statements that could help with this? Basically, if ‘show_info’ field is empty, hide ‘#show-info-wrapper’ div.

    Thanks.

  • The best place to get questions like this answered would likely be either from the theme author or more likely from Visual Composer on how to show/not show html based on the value of a custom field.

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

You must be logged in to reply to this topic.