Home › Forums › CSS › Change Home Page Image using Advanced Custom Fields › Re: Change Home Page Image using Advanced Custom Fields
February 19, 2013 at 6:11 pm
#125331
Member
Why make the user change the URL to the image when you can just get them to upload a new image themselves?
Using ACF, you can simply add an image field to your home page and then use the following code in your template:
$home_image = get_field(‘your_field_name’);
if( $home_image ) {
echo wp_get_attachment_image( $home_image, $size = ‘full’ );
} else {
echo ““;
}
?>
I’m using `wp_get_attachment_image` here, but that depends on you selecting ‘Image ID’ as the ‘Return Value’ when you create your custom field.