N
N
nextnull2018-07-15 17:23:31
WordPress
nextnull, 2018-07-15 17:23:31

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&amp;showinfo=0" frameborder="0" allow="autoplay; encrypted-media" allowfullscreen></iframe>
</div>

hide this block

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Mamenko, 2018-07-15
@nextnull

<?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&amp;showinfo=0" frameborder="0" allow="autoplay; encrypted-media" allowfullscreen></iframe>
</div>
<?php endif; ?>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question