Answer the question
In order to leave comments, you need to log in
How to hide a field if the value is empty?
hello,
there is a site on vorpress, there are arbitrary fields.
How to do if the field is empty, not displayed?
<div id = "video">
<iframe width="100%" height="315" src="https://www.youtube.com/embed/<?php echo get_field( "video", $post_id ); ?>?rel=0&showinfo=0" frameborder="0" allow="autoplay; encrypted-media" allowfullscreen></iframe>
</div>
Answer the question
In order to leave comments, you need to log in
<?php if get_field( "video", $post_id ) : ?>
<div id = "video">
<iframe width="100%" height="315" src="https://www.youtube.com/embed/<?php echo get_field( "video", $post_id ); ?>?rel=0&showinfo=0" frameborder="0" allow="autoplay; encrypted-media" allowfullscreen></iframe>
</div>
<?php endif; ?>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question