• I am trying to set up fields to include links on a profile page to linkedin and twitter etc but I am having problems if the profile does not have a link to add in this field; the field still shows when I publish.

    Below is the code I am using, can anyone help?

    <ul class="related-links-list">
      <li><a href="<?php the_field('linkedin'); ?>" target="_blank">Connect with me on LinkedIn</a></li>
      <li><a href="<?php the_field('twitter'); ?>" target="_blank">Follow me on Twitter</a></li>
      </ul>
Viewing 1 replies (of 1 total)
  • Maybe you should try something like:

    <?php if ( get_field('linkedin')){ ?>
    <li><a href="<?php the_field('linkedin'); ?>" target="_blank">Connect with me on LinkedIn</a></li>
    <?php } ?>

    … etc …

Viewing 1 replies (of 1 total)
  • The topic ‘Conditional Fields’ is closed to new replies.