I am displaying a div in the Edit Post screen using add_meta_box()
. This function provides very limited positioning options via “priority” and “context” params and these are not sufficient for my needs.
I need to be able to display the div below the Permalink but above the Insert Media button on Edit Post, specifically below the div “titlediv”, above the div “postdivrich”.
How else can I position the meta box on the post edit screen? Can this be done through jQuery?
Here’s a partially working solution:
function admin_init(){
add_meta_box("wd_meta", "WD Meta", "wd_meta", "post", "normal", "high");
}
add_action("admin_init", "admin_init");
function wd_meta() {
global $post;
$custom = get_post_custom($post->ID);
?>
<div id="wdMeta">
<p>Display a message here.</p>
</div>
<script>
$('#wd_meta').insertAfter('#titlediv');
</script>
<?php } ?>
The meta box is displaying on the page correctly, but the javascript is not positioning it correctly, even though it appears to work in demo:
You cannot use a real metabox to do that, hook into
edit_form_after_title
instead.Here is a simple example: