Advanced Custom Fields was one of the first plugins I ever reviewed on this site.…
Custom Fields make WordPress infinitely more expandable and are one of the reasons it now serves as a full-blown CMS. Essentially, custom fields are just pieces of meta-data, with a key and a value (or multiple values). But, they can be a bit of a pain to set-up, and hard to hook into. Advanced Custom Fields aims to make this process a bit simpler. And it’s pretty successful too. I use it on just about every project, so I’m happy to give it a vote of confidence.
What’s It Do?
When you install ACF, it will add a new section to your admin panel called “Custom Fields.” This gives you access to a GUI that lets you add groups of custom fields, define conditional rules, and customize styling. There are different custom field types to choose from, a checkbox, a WYSIWYG editor, a date picker, or just a plain old text box. And if you need a little more, there are several premium add-ons to choose from.
For developers out there, ACF also comes with quite a few functions, actions and filter which make it pretty easy to hook into custom field data and output it to your theme in a variety of ways.
How’s It Work?
To get started, you’ll want to go to the Custom Fields section that has been added to your admin panel. From there, you can create a new field group and start adding fields. When you add a field, you’ll be given a list of parameters to fill out, which vary depending on the type of custom field you chose. Just follow the instructions, but you can usually leave most options by default.
You’ll also be able to customize how the meta boxes will look on your post edit pages. You can create a standard meta box, or leave it open with the “No Metabox” option. You can also organize groups and individual fields into tables or rows.
Make sure you pay attention to conditions and location. You can set up a few rules so that your custom fields only appear on certain post types. For instance, you can have it appear on just posts, pages or custom post types, only on certain templates, or only in certain taxonomy categories. Take full advantage of these options. When you leave the field groups on pages where they are not needed, custom field values will still be assigned. En masse, this can cause some real bloat in your database, so limit the location of field groups to just what you need.
The last thing you’ll need to do is add the field data to your theme files. Most of the time, simply inserting a the_field('field_name);
just as you would the_title(); will be enough to display field data. Some field types will require a little more effort. For instance, for a checkbox, you’ll have to check an array to see if conditional criteria are met, like so:
<?php /* * Conditional statement (Checkbox rvalue is an array) */ if( in_array( 'red', get_field('field_name') ) ) { //... } ?>
Visit the ACF docs page for more info on this.
Costs, Caveats, Etc.
Advanced Custom Fields is available for free in the Plugin Repository. However, there are several add-ons which cost about $25 (AUD) a piece, one-time fee, and can save you a boatload of time. I use the Flexible content and Repeater fields a lot in my CMS customizations. Can’t imagine life without them.
Elliot updates his plugin frequently and is constantly addressing bugs and extensions. The most recent major release, 4.0, also saw an improvement in how add-ons are installed, so ACF is still very much in active development.
On the ACF there is a dedicated forum where Elliot addresses problems peoples problems. I’ve had a couple myself and have heard back in just under a few days. There is a sizable community around the plugin as well, so you can expect that help will be more than available to you.