'Hide ACF fields in the front-end when one of them is empty
I am currently trying to show fields in the front-end, however they're files/uploads. So they're not always used. I am trying to work out how you hide fields when there is no upload. I currently have this code after researching some bits, but it isn't working. I do apologise, I am currently still learning PHP.
Any help would be greatly appreciated.
function woo_new_tab_content() {
// The new tab content
if (get_field ('tech_sheet'));
echo '<h3><a href="'. get_field('tech_sheet') .'" target="_blank">Download Tech Sheet</a></h3>';
if (get_field ('datasheet'));
echo '<h3><a href="'. get_field('datasheet') .'" target="_blank">Download Datasheet</a></h3>';
if (get_field ('datasheet_2'));
echo '<h3><a href="'. get_field('datasheet_2') .'" target="_blank">Download Datasheet</a></h3>';
if (get_field ('datasheet_3'));
echo '<h3><a href="'. get_field('datasheet_3') .'" target="_blank">Download Datasheet</a></h3>';
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|