Home › Forums › Front-end Issues › Only Display data if True › Reply To: Only Display data if True
Hi Beth.
Well, if you validate it with a simple if, something like this:
<?php if ( get_field('fireplace' ) ) : ?>
// do something
<?php the_field('fireplace'); ?>
<?php endif; ?>
This will show the field only if the field “fireplace” have something, this works with text fields and any field as well.
Here the docs about it https://www.advancedcustomfields.com/resources/true-false/
Like a extra point. To print the value of a custom field, you can use directly the function the_field('your_field_name')
but if do you want to check or save the value of the field in a variable, you can use get_field('your_field_name')
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.