Good afternoon, let's see if you can give me a little hand.
The subject I think is easy but I can not find the solution because I am more a designer than a programmer.
I have in a Wordpress with "Advanced Custom Fields" a Repeater Field with TV channels of various types.
I need to show only channels of the news type, with the 'type' field being a drop-down list.
<?php if( have_rows('canales_paquete_basico') ): ?>
<?php while( have_rows('canales_paquete_basico') ): the_row();
$value = get_sub_field('tipo');
if( $value === 'noticias' );
?>
<div class="col-md-2 col-sm-4 col-xs-6">
<figure class="canales-tv">
<img src="<?php the_sub_field('imagen') ?>" class="img-responsive" alt="">
<figcaption>
<strong><?php the_sub_field('nombre'); ?></strong><br/>
<span class="label label-default"><?php the_sub_field('tipo'); ?></span>
</figcaption>
</figure>
</div>
<?php endwhile; ?>
<?php endif; ?>
Any suggestions? Thank you very much in advance.
EDITION: Partial solution
I finally got it, but it paints me the result of the type field outside the div.
Does anyone know why it happens?
The updated code.
<?php
if(have_rows('canales_paquete_basico', 10)):
while(have_rows('canales_paquete_basico', 10)): the_row();
if(get_sub_field('tipo', 10) == 'generalista'):
the_sub_field('tipo', 10); ?>
<div class="col-md-2 col-sm-4 col-xs-6">
<figure class="canales-tv">
<img src="<?php the_sub_field('imagen', 10) ?>" class="img-responsive" alt="">
<figcaption>
<strong><?php the_sub_field('nombre', 10); ?></strong><br/>
<span class="label label-default"><?php the_sub_field('tipo', 10); ?></span>
</figcaption>
</figure>
</div>
<?php endif; ?>
<?php endwhile; ?>
<?php endif; ?>
FINAL SOLUTION. Pes nothing, I stew it, I eat it. I leave here the code with the result in case someone serves him.
<?php
if(have_rows('canales_paquete_basico', 10)):
while(have_rows('canales_paquete_basico', 10)): the_row();
if(get_sub_field('tipo', 10) == 'generalista'):
?>
<div class="col-md-2 col-sm-4 col-xs-6">
<figure class="canales-tv">
<img src="<?php the_sub_field('imagen', 10) ?>" class="img-responsive" alt="">
<figcaption>
<strong><?php the_sub_field('nombre', 10); ?></strong><br/>
<span class="label label-default"><?php the_sub_field('tipo', 10); ?></span>
</figcaption>
</figure>
</div>
<?php endif; ?>
<?php endwhile; ?>
<?php endif; ?>