Home › Forums › General Issues › Changing image URL to Attachment Page URL › Reply To: Changing image URL to Attachment Page URL
get_attachment_link(...) which returns the URI of the attachment field. Use the following code:
Change your code to the following:
<?php $images = get_field('photos'); if( $images ): ?> <div id="gallery"> <h3>Photos</h3> <?php foreach( $images as $image ): ?> <a class="tooltip" href="<?php echo get_attachment_link($image['ID']); ?>"> <span> <img src="<?php echo $image['sizes']['medium']; ?>" alt="<?php echo $image['alt']; ?>" /> </span> </a> <?php endforeach; ?> </div> <?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!
🚨 The 2023 ACF Annual Survey closes tomorrow! This is your last chance to complete the survey and help guide the evolution of ACF. https://t.co/0cgr9ZFOJ5— Advanced Custom Fields (@wp_acf) May 18, 2023
© 2023 Advanced Custom Fields.