How can I show <li> only if custom field has content

I have the following code:

font size="2"Pistas:/font/p
ul
li
  ?php

echo types_render_field("pista-1a", array("argument1"="value1","argument2"="value2","argument2"="value2"));

?li
?php

echo types_render_field("pista-1b", array("argument1"="value1","argument2"="value2","argument2"="value2"));

? /li/ul       '

As you can see... I manually inserted

  • in every item, but sometimes not all fields have contents, so in this case, the
  • bullets show with no content in front of them.. how can I change the code to insert
  • only if the custom field is not empty.... (I'm using Types Plugin)

    Sorry for my basic coding, I'm not a programmer and I'm learning a little as I try to adapt my theme to my needs

    Thanks a lot folks!

  • Topic plugin-types php customization Wordpress

    Category Web


    Again, I'm not familiar with Advanced Custom Fields but you may be able to store the returned value into a variable then test if that variable is empty, like so:

    <?php
        $pista1a = types_render_field("pista-1a", array("argument1"=>"value1","argument2"=>"value2","argument2"=>"value2"));
    ?>
    <ul>
    
      <?php if( ! empty( $pista1a ) ) : ?>
    
        <li>
            <?php echo $pista1a; ?>
        </li>
    
      <?php endif; ?>
    
    </ul>
    

    About

    Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.