Reputation: 11
Can someone know the answer about it I have field set and i want when they are empty show some text now there is showing nothing
<div class="place-bottom-row">
<?php if(get_field('pojedynczy_wpis')):
$i = 0;
$today = date('d-m-Y'); //This has to match the format of your 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 -->
Upvotes: 1
Views: 1606
Reputation: 27092
Rather than using the_sub_field()
(which echo
es the return value), you should use get_sub_field():
<?php echo get_sub_field('danie_rodzaj') ? get_sub_field('danie_rodzaj') : 'Custom Text instead'; ?>
This will allow you to test if there's a value, before echoing it.
Upvotes: 1