Misc / Adding Fields After the Title

Adding FM fields between the title and the main content editor is a fairly simple process that can be broken down into three basic steps:

  1. Render the meta boxes to appear in some uniquely defined context–(uniquely defined context as in not 'normal', 'side', or 'advanced'). Here,'my_after_title' is used.
  2. unset the unique context from $wp_meta_boxes['post'].
  3. Set the $context argument of any $fm->add_meta_box() calls to match the unique context from above.

The hook, edit_form_after_title is used to achieve the first and second steps.

Set up the context:

function my_edit_form_after_title() {
    // get globals vars
    global $post, $wp_meta_boxes;

    // render the FM meta box in 'my_after_title' context
    do_meta_boxes( get_current_screen(), 'my_after_title', $post );

    // unset 'my_after_title' context from the post's meta boxes
    unset( $wp_meta_boxes['post']['my_after_title'] );
add_action( 'edit_form_after_title', 'my_edit_form_after_title' );

Use the context:

function my_after_title_fm_fields() {
    $fm = new Fieldmanager_Group( array(
        'name'     => 'after_title_fm_fields',
        'children' => array(
            'After Title Text' => new Fieldmanager_TextField( 'After Title Text' ) ),
            'After Title Link' => new Fieldmanager_Link( 'After Title Link' ),
    ) );

    $fm->add_meta_box( 'After Title', array( 'post' ), 'my_after_title', 'high' );
add_action( 'fm_post_post', 'my_after_title_fm_fields' );

Once executed properly, you should be able to now drag other draggable meta boxes in and out of this context.