There is a way to put that meta box after the title. There is a hook called edit_form_after_title
. If you look at the source there is no hook earlier than that that isn’t much too early– outside of the <form
tag. The following does move that box to the location after the title…
function generic_box() {
remove_meta_box('postcustom',null,'core');
add_meta_box('postcustomv2', __('Custom Fields'), 'post_custom_meta_box', 'post', 'after_title');
}
add_action('do_meta_boxes','generic_box',100);
function add_box_after_title() {
global $post_type, $post;
do_meta_boxes($post_type, 'after_title', $post);
}
add_action( 'edit_form_after_title', 'add_box_after_title' );
… but there is a slight issue. I can’t seem to get the box to remove and then add it back with the same ID. I’ve added it back as postcustomv2
but it is the same callback. This results in a slight formatting glitch but it seems to work.
Edit:
I thought of a way to cheat… a lot. No guarantees of functionality with this one.
function title_cheat() {
global $post; ?>
<div id="titlewrap">
<label class="screen-reader-text" id="title-prompt-text" for="title"><?php echo apply_filters( 'enter_title_here', __( 'Enter title here' ), $post ); ?></label>
<input type="text" name="post_title" size="30" value="<?php echo esc_attr( htmlspecialchars( $post->post_title ) ); ?>" id="title" autocomplete="off" />
</div><?php
}
function generic_box() {
remove_meta_box('postcustom',null,'core');
remove_post_type_support('post','title');
add_meta_box('postcustomv2', __('Custom Fields'), 'post_custom_meta_box', 'post', 'after_title');
add_meta_box(
'titlediv', // id, used as the html id att
__( 'Title' ), // meta box title
'title_cheat', // callback function, spits out the content
'post', // post type or page. This adds to posts only
'after_title', // context, where on the screen
'low' // priority, where should this go in the context
);
}
add_action('do_meta_boxes','generic_box',100);
function add_box_after_title() {
global $post_type, $post;
do_meta_boxes($post_type, 'after_title', $post);
}
add_action( 'edit_form_after_title', 'add_box_after_title' );
If you remove post type support for the “title” the title box disappears, and you can then add it back where you want.
Barely tested. Possibly buggy. Caveat emptor. No refunds.