2

I'm using this code.

add_filter('meta-box-order_post','one_column_for_all');
function one_column_for_all($result, $option, $user){
    $result['normal'] = 'postexcerpt,formatdiv,trackbacksdiv,tagsdiv-post_tag,categorydiv,postimagediv,postcustom,commentstatusdiv,slugdiv,authordiv,submitdiv';
    $result['side'] = '';
    $result['advanced'] = '';
    return $result;
}

My submitdiv always appearing in the middle instead of bottom. Can anyone help me to move it to the bottom?

Please note: I also have some custom metaboxes which is added by some plugins. So i want to move the submitdiv very bottom of the page

1 Answer 1

3

Try something like this:

// First make all metaboxes have 'normal' context (note the absence of 'submitdiv')
// If you know the ids of the metaboxes, you could add them here and skip the next function altogether
add_filter('get_user_option_meta-box-order_post', 'one_column_for_all', 10, 1);
function one_column_for_all($option) {
    $result['normal'] = 'postexcerpt,formatdiv,trackbacksdiv,tagsdiv-post_tag,categorydiv,postimagediv,postcustom,commentstatusdiv,slugdiv,authordiv';
    $result['side'] = '';
    $result['advanced'] = '';
    return $result;
}

// Then we add 'submitdiv' on the bottom, by creating this filter with a low priority
// It feels a bit like overkill, because it assumes other plug-ins might be using the same filter, but still...
add_filter('get_user_option_meta-box-order_post','submitdiv_at_bottom', 999, 1);
function submitdiv_at_bottom($result){
    $result['normal'] .= ',submitdiv';
    return $result;
}

And since you're forcing content into one column, you might want to add these for design consistency:

// Allow only 1 column option on screen options
add_filter('screen_layout_columns', 'one_column_on_screen_options');
function one_column_on_screen_options($columns) {
    $columns['post'] = 1;
    return $columns;
}

// Ignore user preferences stored in DB, and serve only one column layout    
add_filter('get_user_option_screen_layout_post', 'one_column_layout');
function one_column_layout($option) {
    return 1;
}

I'm assuming you're talking about normal posts, which is what I've shown above, but these could be adapted to other post types as well, I guess, using different filters.

2
  • Hello Tomas, Its a great answer. Thanks for your time. I tried your code. You used the same function twice. one_column_for_all. So please update your answer by giving unique functions. It will be helpful for others. And one more thing.. I still have some problems. meta boxes which created by plugins still positioned at the bottom of submitdiv. Any ideas to move it above submit div? Feb 9, 2012 at 21:15
  • Sorry about that. I've fixed the answer. As for the other metaboxes, do you have their ids? If so, can you include them on the first filter? Feb 9, 2012 at 22:15

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.