title: How to show ACF Sub Field only if the value is set, if not, hide?
body: <p>I'm using ACF, flexible-content. </p>
  
  <p>I have made media fields for facebook, twitter and more.</p>
  
  <p>The fields will get the link, as the front-end is just the logo of the company.</p>
  
  <p>I need to show the html, only if the value is set, if not, don't show it. </p>
  
  <p>How can I accomplish this? I need something like this:</p>
  
  <pre><code>                       if( get_row_layout() == 'social_media_icons' ): ?&gt;
  
                              if get_sub_field('media_facebook') is set, show this {
                              &lt;li class="author-profile__social-item"&gt;&lt;a rel="noopener noreferrer" href="&lt;?php echo get_sub_field('media_facebook'); ?&gt;" class="author-profile__social-anchor" target="_blank"&gt;&lt;i class="fa fa-facebook" aria-hidden="true"&gt;&lt;/i&gt;&lt;/a&gt;&lt;/li&gt; 
                              }
  
                              if get_sub_field('media_twitter') is set, show this {
                              &lt;li&gt;Twitter&lt;/li&gt;
                              }
  
                          &lt;?php endif; ?&gt;
  </code></pre>
  
  <p>I have tried this:</p>
  
  <pre><code>  &lt;?php
  
                  while ( have_posts() ) : the_post();
  
                  if( have_rows('social_media','user_'. $author_id) ):
  
                      while ( have_rows('social_media', 'user_'. $author_id) ) : the_row();
  
                          if( get_row_layout() == 'social_media_icons' ): ?&gt;
  
                              &lt;?php if (get_sub_field('media_facebook')) { ?&gt;
                              &lt;li class="author-profile__social-item"&gt;&lt;a rel="noopener noreferrer" href="&lt;?php echo get_sub_field('media_facebook'); ?&gt;" class="author-profile__social-anchor" target="_blank"&gt;&lt;i class="fa fa-facebook" aria-hidden="true"&gt;&lt;/i&gt;&lt;/a&gt;&lt;/li&gt; 
                              &lt;?php } ?&gt;
  
                              &lt;?php if (get_sub_field('media_twitter')) { ?&gt;
                              &lt;li class="author-profile__social-item"&gt;&lt;a rel="noopener noreferrer" href="&lt;?php echo get_sub_field('media_twitter'); ?&gt;" class="author-profile__social-anchor" target="_blank"&gt;&lt;i class="fa fa-twitter" aria-hidden="true"&gt;&lt;/i&gt;&lt;/a&gt;&lt;/li&gt;
                              &lt;?php } ?&gt;
  
                              &lt;?php if (get_sub_field('media_github')) { ?&gt;
                              &lt;li class="author-profile__social-item"&gt;&lt;a rel="noopener noreferrer" href="&lt;?php echo get_sub_field('media_github'); ?&gt;" class="author-profile__social-anchor" target="_blank"&gt;&lt;i class="fa fa-github" aria-hidden="true"&gt;&lt;/i&gt;&lt;/a&gt;&lt;/li&gt;
                              &lt;?php } ?&gt;
  
                              &lt;?php if (get_sub_field('media_linkedin')) { ?&gt;
                              &lt;li class="author-profile__social-item"&gt;&lt;a rel="noopener noreferrer" href="&lt;?php echo get_sub_field('media_linkedin'); ?&gt;" class="author-profile__social-anchor" target="_blank"&gt;&lt;i class="fa fa-linkedin-square" aria-hidden="true"&gt;&lt;/i&gt;&lt;/a&gt;&lt;/li&gt;
                              &lt;?php } ?&gt;
  
                              &lt;?php if (get_sub_field('media_google')) { ?&gt;
                              &lt;li class="author-profile__social-item"&gt;&lt;a rel="noopener noreferrer" href="&lt;?php echo get_sub_field('media_google'); ?&gt;" class="author-profile__social-anchor" target="_blank"&gt;&lt;i class="fa fa-google-plus-official" aria-hidden="true"&gt;&lt;/i&gt;&lt;/a&gt;&lt;/li&gt;
                              &lt;?php } ?&gt;
  
                              &lt;?php if (get_sub_field('media_reddit')) { ?&gt;
                               &lt;li class="author-profile__social-item"&gt;&lt;a rel="noopener noreferrer" href="&lt;?php echo get_sub_field('media_reddit'); ?&gt;" class="author-profile__social-anchor" target="_blank"&gt;&lt;i class="fa fa-reddit-alien" aria-hidden="true"&gt;&lt;/i&gt;&lt;/i&gt;&lt;/a&gt;&lt;/li&gt;
                              &lt;?php } ?&gt;
  
                              &lt;?php if (get_sub_field('media_personal_website')) { ?&gt;
                               &lt;li class="author-profile__social-item"&gt;&lt;a rel="noopener noreferrer" href="&lt;?php echo get_sub_field('media_personal_website'); ?&gt;" class="author-profile__social-anchor" target="_blank"&gt;&lt;i class="fa fa-globe" aria-hidden="true"&gt;&lt;/i&gt;&lt;/a&gt;&lt;/li&gt;
                              &lt;?php } ?&gt;
  
                          &lt;?php endif; ?&gt;
                    &lt;?php  endwhile;
  
                      else :
                          echo 'no content';
                      endif;
  
  
                  endwhile; // End of the loop.
  
                  ?&gt;
  </code></pre>
  
  <p>However, what is this, but it shows 3times each. </p>
  
  <p>So it shows facebook, git,linke, facebook, git, linke, facebook, git, linke</p>
  
  <p>It doesn't show those where the value isn't set. </p>
  
  <p>How can I not make them repeat those who are set? </p>
  
  <p>ACF Flexible Content </p>