<div class="full-width awards">
<h2><span>Awards</span></h2>
<div id="accordion" class="accordion awards-list">
<?php if (get_field( 'awards_&_festivals' ) ) : ?>
<h3 class="award-title" ><span class="down-icon">Awards & Festivals</span></h3>
<div class="award-content" >
<?php the_field( 'awards_&_festivals' ); ?>
</div>
<?php endif; ?>
</div>
I wanted to hide the awards div when the_field does not have any content any idea on how to make this happen? Much appreciated.
With css you can hide it with :empty
property
like
.someClass:empty {
display:none;
}
We can do it like this -
if ($(".award-content").html() == "") {
$('.awards').hide();
}
You can verify with PHP if has content and ignore div. With CSS you can use :empty selector http://www.w3schools.com/cssref/sel_empty.asp
.award-content:empty {
display: none;
}
Or change you PHP code:
<div class="full-width awards">
<h2><span>Awards</span></h2>
<div id="accordion" class="accordion awards-list">
<?php if (!empty(get_field( 'awards_&_festivals' ) )) : ?>
<h3 class="award-title" ><span class="down-icon">Awards & Festivals</span></h3>
<div class="award-content" >
<?php the_field( 'awards_&_festivals' ); ?>
</div>
<?php endif; ?>
</div>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.