Home › Forums › General Issues › Display/hide multiple fields based on value › Reply To: Display/hide multiple fields based on value
Hi,
you should store your other field in a variable as well,
Then before rendering your blockquote your run an if statement that check if the testimonial is available, if it’s not it skips the blockquote part
someting like:
$testimonial = get_field('testimonial');
if($testimonial && !empty($testimonial)){
// build your quote blockquote with the if img...
}
this case doesn’t test for the name if you want the testimonial AND the name you should write:
$testimonial = get_field('testimonial');
$name = get_field('name);
if($testimonial && !empty($testimonial) && $name && !empty($name)){
// build your quote block with the if img...
}
I haven’t tested this code but an if statement before your <blokquote> building is what you need, you can find more info about the if “or”, “and” conditions here if you want to set up something more complex.
http://www.php.net/manual/en/language.operators.logical.php
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!
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 Privacy Policy. If you continue to use this site, you consent to our use of cookies.