I am using ACF repeater plugin on my wordpress site to generate simple gallery. this si the code in my tempalte file:
<?php if( have_rows('gallery') ): ?>
<ul class="slides">
<?php while( have_rows('gallery') ): the_row();
// vars
$image = get_sub_field('gallery_images');
?>
<li class="slide">
<img src="<?php echo $image['url']; ?>" alt=""/>
</li>
<?php endwhile; ?>
</ul>
<?php endif; ?>
And this is html output on frontpage:
<ul class="slides">
<li class="slide"><img alt="" src="h"></li>
</ul>
The image src outputs "h"... I have double checked and the sub_field “slider_images” is set to be Image URL. I copied the code from documentation, didn't change anything. What am I missing?
If you're outputting the URL from the ACF directly, I don't think you need the echo $image['url']
anymore. echo $image
will do.
You should use while(have_rows('gallery_images'))
and get_sub_field('url')
then echo $image
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.