Custom Meta Boxes: multiple fields within a repeatable field

Try Fieldmanager. It was built with repeating groups being priority #1. Your new code would look something like this:

add_action( 'init', function() {
    $fm = new Fieldmanager_Group( array(
        'name'           => 'artists',
        'limit'          => 0,
        'label'          => 'New Artist',
        'label_macro'    => array( 'Artist: %s', 'name' ),
        'add_more_label' => 'Add another Artist',
        'children'       => array(
            'name'      => new Fieldmanager_Textfield( 'Name' ),
            'website'   => new Fieldmanager_Link( 'Website' ),
            'headliner' => new Fieldmanager_Checkbox( 'Headliner' )
            )
        ) );
    $fm->add_meta_box( 'Artists', array( 'post' ) );
} );

Disclosure: The company I work for open-sources this plugin.

Leave a Comment