What is ACF?

Overview

Advanced Custom Fields is a free WordPress plugin which acts as a GUI layer for custom fields. Custom fields are native to WP and appear on pages, posts and custom post types, however the native custom field interface are not very user friendly. Here is the difference between native custom fields and Advanced Custom Fields.

Field Groups

A field group contains your custom fields, location rules and display options. Each field group will use it’s location rules to display it’s fields on a specific edit screen, and then use the display options to customize the page. This is what a typical field group looks like:

acf-field-group-example

Fields

Within a field group you can create your fields. An example of this would be a field group called “Artist” which contains 2 fields “Biography” and “Thumbnail”.

Each field has a wide array of options to change it’s type (text, select, check-box, wysiwyg editor, etc), default value, required status, etc. You can even purchase Add-ons to unlock more powerful field types such as repeater, gallery and flexible content.

Location Rules

Similar to the itunes smart playlist rules, the ACF location rules allow you to connect a field group to an edit screen. There are different types of rule connectors, such as post type, post ID, page template, taxonomy, etc.

Display Options

When a field group appears on an edit screen, the field group’s display options will be loaded. These allow you to hide elements on the page. For example, you may want to hide the default editor when the “Artist” field group is shown. This helps to minimise the edit screen and provide a more user friendly experience to the content enter-er.

Displaying ACF data in your theme

ACF features an easy to use and powerful library of functions to load and display custom field data. It is based off and uses the native WP postmeta functions, but also formats the value based on the field’s type and field’s settings. This allows you to write less code and produce smarter websites!

ACF requires you to have some prior knowledge of modifying your theme and understanding PHP code. Once you are editing the correct template file, a simple the_field('hero_text') will echo (display) the value, and get_field('hero_text') will return it for use as a variable. Be sure to read over all the available functions before starting work on the theme to ensure you only have to write the code once!

Conclusion

ACF is a GUI layer for custom fields but is not a “1 click wonder” plugin. This plugin will allow you to easily save data to posts but will not magically display it on your website. For that, you need to edit your theme and create the desired markup.

ACF is light weight but powerful. You can create front end forms, global options pages and even save custom field data to taxonomy terms, media attachments and users!