I have a custom post type with a custom field created with Advanced Custom Fields. I can retrieve all of the posts of this type and display the images with the following code:
<?php
$args = array( 'post_type' => 'image' );
$loop = new WP_Query( $args );
while ( $loop->have_posts() ) : $loop->the_post(); ?>
<?php $image = get_field('image_file'); ?>
<img src="<?php echo $image['url']; ?>" />
<?php endwhile; ?>
However, I want to be able to retrieve a single image url without looping through all of them. How would I go about this?
I've tried this:
<?php
$args = array( 'post_type' => 'image', 'title' => 'Welcome to bird - image 1' );
$loop = new WP_Query( $args );
while ( $loop->have_posts() ) : $loop->the_post(); ?>
<?php $image = get_field('image_file'); ?>
<img src="<?php echo $image['url']; ?>" />
<?php endwhile; ?>
But it outputs the entire list - how can I just get a single post? If it helps, the permalink is like this:
/?image=welcome-to-bird-image-1