Skip to content

Instantly share code, notes, and snippets.

@ahaywood
Created November 7, 2017 00:46
Show Gist options
  • Save ahaywood/8d6b51eaf070ffe19c9384b89a216992 to your computer and use it in GitHub Desktop.
Save ahaywood/8d6b51eaf070ffe19c9384b89a216992 to your computer and use it in GitHub Desktop.
WP: Three ways to display an image
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<?php // ACF
$image = get_field('extra_image');
var_dump($image);
?>
<img src="<?= $image['url']; ?>" alt="<?= $image['alt']; ?>">
<?php // FEATURED IMAGE >> IMAGE TAG
the_post_thumbnail();
// FEATURED IMAGE >> URL
if ( has_post_thumbnail()) {
$thumbnail = wp_get_attachment_image_src( get_post_thumbnail_id(), 'large');
echo $thumbnail[0];
}
?>
<?php endwhile; endif; ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment