Home › Forums › General Issues › Detect if field is hidden by conditional logic › Reply To: Detect if field is hidden by conditional logic
You can also name a select field $footer with options yes/no. Then just do a conditional statement based on the $footer value.
<?php
if(get_field('$footer') == "yes")
{
//...
} else {
//...
}
?>
or just
<?php if( get_field('$footer') ): ?>
//...
<?php endif; ?>
As far as returning null, you can skip the option to show the footer and just check if data has been entered into each of the footer column fields. If no, the field wont show.
<?php
$col_1 = get_field('$footer_col_1');
$col_2 = get_field('$footer_col_2');
$col_3 = get_field('$footer_col_3');
if($col_1) {
echo $col_1;
}
if($col_2) {
echo $col_2;
}
if($col_3) {
echo $col_3;
}
?>
Lots of options, so just go with the method that works best for you.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
🎉ACF has made it into the latest round of the @TheTorqueMag Plugin Madness!
— Advanced Custom Fields (@wp_acf) March 22, 2023
🙏 Please swing by and vote for ACF in the latest matchup.
🙌 Each round lasts one week, but you can vote twice each week. Make sure to get both your votes in!https://t.co/iTpRE82O1k
© 2023 Advanced Custom Fields.
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Cookie Policy. If you continue to use this site, you consent to our use of cookies.