Reputation: 619
I have used ACF plugin to add custom post meta box image field. My custom image field name is homepage_full_width.
How can i display post thumbnail image using this custom field image.
thanks.
Upvotes: 3
Views: 4718
Reputation: 41
You can use image ID as the return type of the ACF custom image field then you can use the wp_get_attachment_image()
function to generate the image HTML.
$image = get_field('homepage_full_width');
$size = 'thumbnail'; // (thumbnail, medium, large, full or custom size)
if( $image ) {
echo wp_get_attachment_image( $image, $size );
}
UPDATE
Use image Object as the return type then try
<?php
$imageBg = get_field('homepage_full_width');
$bg = $imageBg ? $imageBg['url'] : '';
?>
<div class="zl-homefullwidth-img parallax_bg skrollable skrollable-between" style="transform: translate3d(0px, 0.382158%, 0px);background-image: url(<?php echo $bg; ?>)"></div>
Upvotes: 4
Reputation: 410
You can do it two ways:
you can use the get_field('homepage_full_width')
in your themes php files where you want it, you can see the documention for it here
You can use and shortcode to display it: [acf field="homepage_full_width"]
You can read the documention for the shortcode here
Upvotes: 0