Hello.
I have a repeater field with a select sub field.
I have 4 options in select field with value and label, and value returned both
I use this code to retrieve value and label. I want to use label as a title and value to get an image related to that title.
But i only get the label, not the value
<?php
// check if the repeater field has rows of data
if( have_rows('servicii_home') ):
// loop through the rows of data
while ( have_rows('servicii_home') ) : the_row();?>
<div class="servHome">
<?php
$serviciu = get_sub_field('denumire_serviciu');
?>
<h2>
<img class="titleIcon" src="<?php bloginfo( 'template_directory' ); ?>/images/<?php echo $serviciu['value']; ?>.png" />
<?php echo $serviciu['label']; ?>
</h2>
<a class="butonul btnBlue">Detalii & tarife</a>
<div class="servCover"></div>
<img class="servBg" src="<?php bloginfo( 'template_directory' ); ?>/images/coafor.jpg" />
</div>
<?php
endwhile;
else :
// no rows found
endif;
?>
Hi @organu
Thanks for the post.
There must be a mistake in your logic.
What is the result from debugging the sub_feld like so:
<div class="servHome">
<?php
$serviciu = get_sub_field('denumire_serviciu');
var_dump($serviciu);
?>
I am looking forward to your respions