Plugin Shoutout : Advanced Custom Fields

Like most developers, I have a tendency to want to code everything from scratch. I suppose like any craftsman, there’s a resistance to relying on a machine to do work you enjoy doing with your hands. But sometimes the challenges of a particular project force your hand and you need to save time on meta boxes and custom fields and spend more time on other aspects of the project. Lately I’ve been relying on Advanced Custom Fields for managing custom fields and I’ve been very impressed.

The interface is smooth and as far as I can tell so far, there’s no front end performance hit. Though, I must admit I do not use the front-end functions provided by ACF and instead prefer to rely on the standard <code>get_post_meta()</code> approach.

But there are two things specifically I enjoy about this plugin. First, it gives you the option to have your “field group” either inside an expandable meta box. This is the standard way custom fields are presented. But it also gives you the ability to add the fields right into the form with no meta box wrapping element. This gives your form some variety. (see screen shots)

The second thing I really enjoy about this plugin is the API for adding custom field types. Developers always love finding an organized API when they need one. For this specific project I need a field where the user could select a NextGen Gallery from a dropdown. All I had to do was create a class extending the acfField. Then add the following to my functions.php:

add_action('acf_register_field','ngg_register_acf_field');
function ngg_register_acf_field() {
add_filter('acf_register_field','ngg_field',0,1);
}

function ngg_field($custom) {
global $acf;
$ngg = array('class'=>'acf_NGG_Gallery','url'=>PATHTODIR.'/acf_ngg.php');
$custom['ngg'] = $ngg;
return $custom;
   }