I’ve a customized publish sort
paintings, and a customized taxonomy
artists. Every publish has at the least one taxonomy time period
artists assigned, e.g. ‘ARTIST NAME 1’.
The Artist taxonomy has a customized area
atist-instagram. Among the phrases (e.g. ‘ARTIST NAME 1’) have a worth of their Instagram customized area (e.g. ‘instausername1’), however others have an empty Instagram area.
On my single publish web page (e.g. ‘ARTWORK 1’), I additionally show the customized time period ‘ARTIST NAME 1’ and this artist’s ‘ARTIST INSTAGRAM’ customized area from the artists taxonomy.
How can I solely show one thing if the customized area of the present publish’s time period isn’t empty?
One other consumer got here up with this code – which appears logical. Nevertheless it would not work. The ‘artist-instagram’ worth is displayed appropriately, however all different echoes throughout the
if !empty rule are ignored. Why is that?
<?php $artists = get_the_terms( get_the_ID(), 'artists' ); if( !empty( $artists ) ) : foreach( $artists as $artist ) : echo 'TEST: <br>'; // This nonetheless works $artistig = the_field( 'artist-instagram', $artist ); if( !empty( $artistig ) ) : echo 'Observe <robust>@'. $artistig .'</robust> on Instagram'; // This doesn't work – area worth is displayed however remainder of echo isn't displayed endif; echo '<br>END TEST'; // This additionally works endforeach; endif; ?>
The way it presently appears to be like with this code:
How I would like it to look:
Observe @instausername1 on Instagram