Created
November 7, 2017 00:46
-
-
Save ahaywood/8d6b51eaf070ffe19c9384b89a216992 to your computer and use it in GitHub Desktop.
WP: Three ways to display an image
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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