Print html when custom field has value inside while loop

isset() is the wrong function to use here. $ct is set because you’re setting it here:

$ct = get_field('cennik_title')

isset() will only be false if $ct was never defined or is set to NULL. get_field() will return false or an empty string if there’s no value and isset() will return true for those.

You want to check if it has a value but is not false or empty. The simplest way to do that is just:

if ( $ct ) :

Leave a Comment