2

I'm having a small issue with the custom post type entry screen. I'd like to bump up my metabox right under the content box, but I'm not sure if that's even possible (as the metaboxes in between are "defaults", i.e.; Excerpt, Discussion & Author).

I'm applying the standard code:

function ctp_admin(){
add_meta_box('cpt_meta', 'Meta Box', 'cpt_meta', 'cpt_function', 'normal', 'high');
}

Thank you!

Noel

4
  • Can't you just drag and drop that section?
    – moettinger
    Commented Jan 10, 2011 at 18:01
  • 1
    It's about the initial placement. For an efficient custom workflow you don't want users to faff about reordering boxes. Most regular users don't even realise they can be reordered. Commented Jan 10, 2011 at 18:23
  • Like Sancho said, not from an initial/automatic point of view. Thank you though!
    – Noel Tock
    Commented Jan 10, 2011 at 19:48
  • Can you add the hook you are calling the ctp_admin function on to your question? Commented Jan 11, 2011 at 11:09

1 Answer 1

4

Where you have the parameter 'normal' eg. the context parameter change that to read 'core'.

add_meta_box('cpt_meta', 'Meta Box', 'cpt_meta', 'cpt_function', 'core', 'high');

The default meta boxes are registered as core and are listed first, followed by the 'normal' context. The docs don't actually say you can do it but I have done without any problems.

EDIT: Make sure your function is registered on the 'add_meta_boxes' hook with a high priority eg:

function my_metabox() {
    ...
}
add_action( 'add_meta_boxes', 'my_metabox', 1 ); // priority 1

The use of 'core' vs. 'normal' may not actually make a difference in the latest version.

2
  • Thank you for that Sancho, I've added it but have had no change so far. I haven't tampered with manually repositioning it, so it shouldn't be affecting it from that angle. I'll still reset the positions within the db and give it another try.
    – Noel Tock
    Commented Jan 10, 2011 at 19:46
  • Ah wait sorry - I think I'm wrong. Can you update your question with the hook you're running your function on? I think using 'normal' context should work if your function is called on the 'add_meta_boxes' action. I'll update my answer if that's the case. Commented Jan 10, 2011 at 20:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.