How to position a custom field before the editor

This can be solved using this nice snippet and edit_form_after_title hook. But I haven’t tested what happens when more than one meta box exists. With a single ACF field (position:normal, style:no-metabox) it works:

add_action( 'edit_form_after_title', 'pre_title_metabox_wpse_94530' );

function pre_title_metabox_wpse_94530() 
{
    global $post, $wp_meta_boxes;

    do_meta_boxes( get_current_screen(), 'normal', $post );

    unset( $wp_meta_boxes['post']['normal'] );
}

And if it has to be solved with jQuery, adjust subtitle_text to your Field Name:

// Add hook to Edit and New post
foreach( array( 'post.php', 'post-new.php' ) as $hook )
    add_action( "admin_footer-$hook", 'move_acf_to_title_wpse_94530' );

function move_acf_to_title_wpse_94530()
{
    // Check post type
    if( 'post' != get_post_type() )
        return;

    ?>
    <script type="text/javascript">
        jQuery(document).ready( function($) 
        {
            $( '#acf-field-subtitle_text' ).css( 'width', '100%' );
            $( '#acf-subtitle_text' ). insertAfter( '#titlewrap' );
        });
    </script>
    <?php
}

Leave a Comment