php - ACF Custom fields empty display text -
can know answer have field set , want when empty show text there showing nothing
<div class="place-bottom-row"> <?php if(get_field('pojedynczy_wpis')): $i = 0; $today = date('d-m-y'); //this has match format of date field ?> <?php while(has_sub_field('pojedynczy_wpis')): ?> <?php if(strtotime($today) <= strtotime(get_sub_field('danie_na_dzien'))){ ?> <?php if($i < 2){ ?> <?php $i++; ?> <?php the_sub_field('danie_rodzaj'); ?> <?php the_sub_field('danie_opis'); ?> <?php the_sub_field('danie_cena'); ?> <?php } ?> <?php } ?> <?php endwhile; ?> <?php else: ?> <?php endif; ?> </div><!-- place bottom row end -->
rather using the_sub_field()
(which echo
es return value), should use get_sub_field():
<?php echo get_sub_field('danie_rodzaj') ? get_sub_field('danie_rodzaj') : 'custom text instead'; ?>
this allow test if there's value, before echoing it.
Comments
Post a Comment