I want to print a block of HTML only when get_field('cennik_title') has value assigned to it inside the loop, when there is no value inserted inside the custom field, the block should be skipped, but in this code the HTML block is printing even I did not insert value for 'cennik_title' custom field, I did use unset(), but its not working, any other way I can achieve it?
<div class="card-body ouroffer">
<?php
$args = array( 'post_type' => 'cennik_post',
'category_name' => 'Stylizacja Rzęs i Paznokci',
'orderby' => 'date',
'order' => 'ASC',);
$cennik_query = new WP_Query ($args);
$i=1;
if(have_posts()) : while ( $cennik_query->have_posts() ) : $cennik_query -> the_post();
?>
<?php $ct = get_field('cennik_title');
if (isset($ct)):
?>
<ol>
<li><?php the_field('cennik_title'); ?></li>
<li>
<ul>
<?php
endif;
?>
<li><a href="<?php echo get_post_permalink() ?>"><span><?php echo $i . ". " ?><?php the_title(); ?></span></a><span><?php the_field('cena'); ?> zł / <?php the_field('trwania'); ?> min</span></li>
<?php
if (isset($ct)):
?>
</ul>
</li>
</ol>
<?php
endif;
?>
<?php
$i++;
unset($ct);
endwhile; endif;
?>
</div>