You’re not running check on whether the artist’s instagram field is empty, you’re running a check on whether the ‘artists’ term is empty, which it isn’t.
<?php
$artistigs = get_the_terms( get_the_ID(), 'artists' );
if( ! empty( $artistigs ) ) : ?>
//This will execute if the artist term is not empty
endif;
?>
I don’t use ACF myself so not 100% sure how stuff like the_field()
works but try this:
<?php
$artists = get_the_terms( get_the_ID(), 'artists' );
if( !empty( $artists ) ) : ?>
<?php foreach( $artists as $artist ) :
$artistig = get_field( 'artist-instagram', $artist );
if( !empty( $artistig ) ) :
echo '<div>';
echo '<i class="fab fa-instagram"></i> <strong><a href="https://instagram.com/' . $artistig . '" target="_blank">@' . $artistig . '</a></strong>';
echo '</div>';
endif;
endforeach;
endif;
?>
================
UPDATE
To address your update, the var_dump()
is really going to mess with formatting, so lets just remove it.
<?php
$artists = get_the_terms( get_the_ID(), 'artists' );
if( !empty( $artists ) ) :
foreach( $artists as $artist ) :
$artistig = get_field( 'artist-instagram', $artist );
if( !empty( $artistig ) ) :
echo 'IG User TEST: '. $artistig .' END TEST';
endif;
endforeach;
endif;
?>