On my custom post type when browsing the site on mobile the Publish metabox will land above other metaboxes. I have changed the position and priority of almost all metaboxes to counter this issue. But there is one metabox I cannot move with priority and context using: https://developer.wordpress.org/reference/functions/add_meta_box/

Is it possible to move the Publish metabox to always be at the bottom when viewing mobile?

It is the default positions I want to change.


You could try removing the 'submitdiv' metabox and re-adding it with a low priority this way:

function benny_default_position_publish_box() {

    remove_meta_box( 'submitdiv', 'post', 'side' );
    remove_meta_box( 'submitdiv', 'page', 'side' );
    //remove_meta_box( 'submitdiv', 'cpt', 'side' );

    add_meta_box( 'submitdiv', __( 'Publish' ), 'post_submit_meta_box', 'post', 'side', 'low' );
    add_meta_box( 'submitdiv', __( 'Publish' ), 'post_submit_meta_box', 'page', 'side', 'low' );
    //add_meta_box( 'submitdiv', __( 'Publish' ), 'post_submit_meta_box', 'cpt', 'side', 'low' );

add_action( 'do_meta_boxes', 'benny_default_position_publish_box' );

But if it doesn't work and you only need it for mobile, you could try setting the user options for sorting the metabox like this:

function benny_user_option_box_position( $order ) {

  if ( wp_is_mobile() ) {

    return array(
        'normal'   => join( ",", array(
            'submitdiv',   // <- keep it last
        ) ),
        'side'     => '',
        'advanced' => '',

  } else {

    return $order;

add_filter( 'get_user_option_meta-box-order_post', 'benny_user_option_box_position' );
add_filter( 'get_user_option_meta-box-order_page', 'benny_user_option_box_position' );
//add_filter( 'get_user_option_meta-box-order_cpt', 'benny_user_option_box_position' );

I haven't tested it but theoretically it should work

| improve this answer | |
  • I have figured out that it doesn't matter which position/priority I have the Publish box set to. side metaboxes will always be shown above advanced metaboxes (which my custom metabox is). Would it be possible to always show side metaboxes at bottom when using mobile? – joq3 Oct 11 '18 at 11:17
  • hi @joq3 the second function (benny_user_option_box_position) is for you; to test it, try replacing wp_is_mobile() with current_user_can( 'manage_options' ), if you are the administrator – benny-ben Oct 11 '18 at 15:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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