Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums CSS Change Home Page Image using Advanced Custom Fields Re: Change Home Page Image using Advanced Custom Fields

#125331
TheDoc
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.