I’ve a customized publish kind
paintings, and a customized taxonomy
artists. Every publish has a minimum of one taxonomy time period
artists assigned, e.g. ‘ARTIST NAME 1’.
The Artist taxonomy has a customized area
atist-instagram. A number of the phrases (e.g. ‘ARTIST NAME 1’) have a price 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 shouldn’t be empty?
One other consumer got here up with this code – which appears logical. However it does not work. The ‘artist-instagram’ worth is displayed accurately, 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 'Comply with <sturdy>@'. $artistig .'</sturdy> on Instagram'; // This doesn't work – area worth is displayed however remainder of echo shouldn't be displayed endif; echo '<br>END TEST'; // This additionally works endforeach; endif; ?>
The way it presently seems with this code:
TEST: instausername1 END TES
How I need it to look:
TEST: Comply with <sturdy>@instausername1</sturdy> on Instagram END TEST