Only display custom field if it there is a value inside

use empty function to check if the return value is empty or not:

   <?php if ( function_exists('get_custom_field_value') ):
        $custom_field_value = get_custom_field_value('Essential info 5', true);
        if(!empty($custom_field_value)):
        ?>
        <li><span>
           <?php echo $custom_field_value; ?>
        </span></li>
        <?php
        endif;
   endif; ?>

also check if the function ‘get_custom_field_value’ is returning with echo statement, you may need to change that to just return the result and not to echo it out.

Hope it solves your problem.

Leave a Comment