Home › Forums › Add-ons › Repeater Field › Hide subfield if it has no text › Reply To: Hide subfield if it has no text
You’ll need to do a check for $row['description']
before actually echoing the <p>
tag – that’s why I placed if( $row['description'])
before echo '<p class="description">...
. This check will simply make sure that $row['description']
is not empty.
If this doesn’t work for you, PHP can also check for empty values in a number of different ways:
http://php.net/manual/en/function.empty.php
http://php.net/manual/en/function.is-null.php
And there’s a discussion of some implementations over at http://techtalk.virendrachandak.com/php-isset-vs-empty-vs-is_null/ !
Ah, and just for ease of reading: http://diffchecker.com/7za0xnhq 🙂
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.