I've built a widget to show pages from a certain category in a dropdown menu. The page that's selected will show up on the homepage. This all works, except the Advanced Custom Fields (ACF) are all showing the same image. I think it's to do with $instance...
The code I'm using is:
<div class="home-image-box"> <?php $attachment_id = get_field('main_image'); $size = "home-boxes"; $image = wp_get_attachment_image_src( $attachment_id, $size ); ?> <a href="<?php echo get_permalink($instance['post_id']); ?>"> <img class="headline" width="<?php echo $image; ?>" height="<?php echo $image; ?>" src="<?php echo $image; ?>" /> </a> </div> <p class="extra-text"><?php the_field('sub_title'); ?></p>
All the code works great on the individual pages - it's just when called by the widget that I get these issues. The title and permalink are using the normal Wordpress functions, and these work fine too.
Are there any ACF users here that can shed some light on this?