Plugin Directory

Test out the new Plugin Directory and let us know what you think.

Developer's Custom Fields

Provides developers with powerful and flexible tools for managing post and user custom fields.

Getting started

Because this code began life just managing custom fields for posts by defining meta boxes for post edit screens, the basic unit here is "the box". However, a "box" can also refer to a section in the user profile screen, or on media attachment edit screens.

A box is defined containing one of more custom fields, each with their own settings. You set a box to be associated with posts (in the generic sense, including pages and custom post types!), users or attachments using the type parameter.

Say you've defined film as a Custom Post Type, and you want to create custom fields to set the director and writer for film posts. You would add something like this to your theme's functions.php (or indeed your plugin code):


if ( function_exists( 'slt_cf_register_box') )
    add_action( 'init', 'register_my_custom_fields' );

function register_my_custom_fields() {
    slt_cf_register_box( array(
        'type'      => 'post',
        'title'     => 'Credits',
        'id'        => 'credits-box',
        'context'   => 'normal',
        'priority'  => 'high',
        'fields'    => array(
                'name'          => 'director',
                'label'         => 'Director',
                'type'          => 'text',
                'scope'         => array( 'film' ),
                'capabilities'  => array( 'edit_posts' )
                'name'          => 'writer',
                'label'         => 'Writer',
                'type'          => 'text',
                'scope'         => array( 'film' ),
                'capabilities'  => array( 'edit_posts' )


Then, when you want to output these values in a loop:


echo '<p>Director: ' . slt_cf_field_value( "director" ) . '</p>';
echo '<p>Writer: ' . slt_cf_field_value( "writer" ) . '</p>';


This is just the beginning! Check the documentation for registering boxes and fields, especially the parameters for fields. The most immediately interesting parameters for fields to check out are: type, scope, options_type.

There are some option query placeholders, for creating dynamic queries to populate select, radio and checkbox fields.

There are also a few hooks. If the plugin currently lacks something you need, odds are you'll be able to hack it using a hook!

If you create a plugin that is dependent on this plugin, use the slt_cf_init hook to intialize your plugin (see this Trac comment).

Note that the internal Google Maps and file selection functionality is designed to be leveraged by theme options pages and other plugins.

Please raise any issues via GitHub. If you're not sure if you've found a genuine issue or not, please start a thread on the WP forum.

NOTE: Some people have found compatibility issues between the WPMU DEV Events+ plugin and this plugin (see here and here). If you find an apparent issue with this plugin and you're also using WPMU DEV Events+, please check for incompatibilities before posting an issue.

Requires: 3.5 or higher
Compatible up to: 4.3.7
Last Updated: 1 year ago
Active Installs: 1,000+


5 out of 5 stars


Got something to say? Need help?


Not enough data

0 people say it works.
0 people say it's broken.

100,3,3 100,3,3 100,3,3 100,1,1 100,2,2
100,2,2 100,2,2