Home › Forums › General Issues › Image link to attachment page › Reply To: Image link to attachment page
You’re going to need to alter the field so that it returns the attachment ID instead of the URL. For more information see WP doc for the functions I use here.
<?php
$images = get_field('galerie_bd');
if( $images ): ?>
<ul class="rslides">
<?php foreach( $images as $image ): ?>
<li>
<a href="<?php echo get_attachment_link($image); ?>">
<?php
$size = 'thumbnail';
$attach = wp_get_attachment_image_src($image, $size);
?>
<img src="<?php echo $attach[0]; ? />" />
</a>
</li>
<?php endforeach; ?>
</ul>
<?php endif; ?>
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.