WordPress.org

Forums

Advanced Custom Fields
Conditional Fields (2 posts)

  1. gemba
    Member
    Posted 1 year 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 1 year 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 ...

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Advanced Custom Fields
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic

Tags

No tags yet.