WordPress.org

Ready to get started?Download WordPress

Forums

Advanced Custom Fields
Conditional Fields (2 posts)

  1. gemba
    Member
    Posted 9 months ago #

    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>
  2. robert_pal
    Member
    Posted 8 months ago #

    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 ...

Reply

You must log in to post.

About this Plugin

About this Topic

Tags

No tags yet.