Adding Images and Other Fields with Advance Custom Fields

Creating an administrative interface that allow users to update information is pretty useful. Doing this in WordPress can be done with a handy little plugin called Advanced Custom Fields.

ACF is very much like Custom Fields, which (in my experience) is a little known and an even littler used bit of functionality built right into WordPress.

Here’s what you need to get an image added at the most basic level.

<img src="<?php the_field('image'); ?>" alt="wp" >

the_field is required and the setup to get all ACF snippets. Within the quotes we have the field_name; which – in this case – is ‘ image ‘. ACF actually allows you to serve up an array, the image URL, or the image ID. You’ll need to choose which of these you’d like to have outputted. For clarity, I’m using the image URL, which is wrapped in HTML. That produces the output of an image with the alt tag of “WP”. Yum.

Leave a Reply

Your email address will not be published. Required fields are marked *