This should probably have been in the Advanced Custom Fields forum, however:
$my_image = wp_get_attachment_image_src(get_sub_field('foto_plato'));
<img src="<?php echo $my_image[0]; ?>
Thread Starter
10rous
(@10rous)
i can’t get it to work
it should be like this?
<ul>
<?php while(has_sub_field('fotos_platos', 'option')): ?>
<li>
<?php $my_image = wp_get_attachment_image_src(get_sub_field('foto_plato')); ?>
<img class="foto" src="<?php echo $my_image[0]; ?>"/>
</li>
<?php endwhile; ?>
</ul>
Is this line right?
<?php while(has_sub_field('fotos_platos', 'option')): ?>
The ‘option’ should be the post ID or left out all together, it defaults to the current post.
Thread Starter
10rous
(@10rous)
I’m working on a php cutom template, that line should be ok WPRanger, as it works for text custom fields in other div within the same template
e.g.
<?php while(has_sub_field('servicios_restaurante', 'option')): ?>
<li style="float:left; padding-left:10px; width:280px; clear:none; padding-right:10px; text-transform:uppercase; font-size:12px; line-height:20px;" id="serv_lista"><p class="dinpro"><?php the_sub_field('servicio') ?></p></li>
<?php endwhile; ?>
I’ve tried to remove the ‘option’ but it doesn’t work either
thanks
Thread Starter
10rous
(@10rous)
solved, checking the image url option in custom field return option
<ul>
<?php while(has_sub_field('fotos', 'option')): ?>
<li><img class="foto" src="<?php the_sub_field('foto') ?>"/></li>
<?php endwhile; ?>
</ul>