Reputation: 45
I have two custom types inside a div. I need hide main div if custom type is empty.
This is my code: (I want to hide div "one"
if "titulo_caja_superior"
custom type is empty.)
<div class="contenidos">
<div class="left">
<div class="one" style="background-color:<?php echo esc_url( of_get_option( 'primary_color' ) ); ?>;color:#FFFFFF;"><div><div class="titulo"><?php the_field('titulo_caja_superior'); ?></div><div class="contenido"><?php the_field('cajaizquno'); ?></div></div>
<div class="two" style="background-color:<?php echo esc_url( of_get_option( 'header_color' ) ); ?>;color:<?php echo esc_url( of_get_option( 'secundary_color' ) ); ?>;"><div class="titulo"><?php the_field('titulo_caja_inferior'); ?></div><div class="contenido"><?php the_field('cajaizqdos'); ?>></div></div>
</div>
</div>
Upvotes: 0
Views: 79
Reputation: 12772
Add an if statement
<div class="contenidos">
<div class="left">
<?php if(!empty(the_field('titulo_caja_superior'))): ?>
<div class="one" style="background-color:<?php echo esc_url( of_get_option( 'primary_color' ) ); ?>;color:#FFFFFF;"><div><div class="titulo"><?php the_field('titulo_caja_superior'); ?></div><div class="contenido"><?php the_field('cajaizquno'); ?></div></div>
<?php endif; ?>
<div class="two" style="background-color:<?php echo esc_url( of_get_option( 'header_color' ) ); ?>;color:<?php echo esc_url( of_get_option( 'secundary_color' ) ); ?>;"><div class="titulo"><?php the_field('titulo_caja_inferior'); ?></div><div class="contenido"><?php the_field('cajaizqdos'); ?>></div></div>
</div>
</div>
Upvotes: 2