Skip to content

Instantly share code, notes, and snippets.

@akmur
Last active August 29, 2015 14:08
Show Gist options
  • Save akmur/3572ee4f43af3821d4bf to your computer and use it in GitHub Desktop.
Save akmur/3572ee4f43af3821d4bf to your computer and use it in GitHub Desktop.
Get Image Field ACF
<?php
// WP_Query arguments
$args = array (
'post_type' => 'page',
'posts_per_page' => '4',
'post_parent' => 9
);
// The Query
$query = new WP_Query( $args );
// The Loop
if ( $query->have_posts() ) {
while ( $query->have_posts() ) {
$query->the_post();
$image = get_field('home_collab_image');
$large_image = $image['sizes'][ 'home-collaborations' ];
?>
<li>
<a href="<?php the_permalink(); ?>">
<img src="<?php echo $large_image; ?>" alt="">
</a>
<div class="name center"><?php the_title(); ?></div>
</li>
<?php
}
} else {
// no posts found
}
// Restore original Post Data
wp_reset_postdata();
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment