7

I've created a plugin using custom post types and I need to force the default two column post page to a single column. At the same time, the Publish metabox must move to the bottom. I need to do this via the functions some how.

I have some solutions from WPSE, but the only solution I've found actually hides the "Publish" metabox. I can't seem to figure out why.

Any ideas of how to do this?

3 Answers 3

8

There is a filter called get_user_option_meta-box-order_{$page} where $page is the name of the post type. Just make sure that submitdiv is the last value in the array:

add_filter( 'get_user_option_meta-box-order_post', 'wpse25793_one_column_for_all' );
function wpse25793_one_column_for_all( $order )
{
    return array(
        'normal'   => join( ",", array(
            'postexcerpt',
            'formatdiv',
            'trackbacksdiv',
            'tagsdiv-post_tag',
            'categorydiv',
            'postimagediv',
            'postcustom',
            'commentstatusdiv',
            'slugdiv',
            'authordiv',
            'submitdiv',
        ) ),
        'side'     => '',
        'advanced' => '',
    );
}
1
  • 1
    I tried your code. But its not working. My post metabox order looks like this as of now. Title,submit,content,custom metaboxes added by plugins,tags Jan 2, 2012 at 8:42
3

One approach is to remove the original metabox, and then to re-add that metabox, with updated parameters. For example, this will move the "Featured Image" meta box from the side column to the main column, for a custom post type with a slug cpt-slug:

Edit

The parameter for the Publish meta box is submitdiv, and the correct callback is post_submit_meta_box(); I've updated the code below to reflect these correct parameters. I've also changed the add_meta_box() $context parameter from 'high' to 'low', so that the Publish meta box will be added at the bottom:

<?php
function wpse25793_move_post_metaboxes( $post ) {
    global $wp_meta_boxes;

    remove_meta_box( 'submitdiv', 'cpt-slug', 'side' );
    add_meta_box( 'submitdiv', __( 'Publish' ), 'post_submit_meta_box', 'cpt-slug', 'normal', 'low' );
}
add_action( 'add_meta_boxes_cpt-slug', 'wpse25793_move_post_metaboxes' );
?>

The approach should be the same for the "Publish" meta box. You just need to remove/add the publish meta box instead of the featured image meta box.

3

To answer the second part of the question - How to force one column, you can do it with get_user_option_screen_layout_{Post_type} filter. Let's say for product post-type:

$func = function( $result, $option, $user ){
    return '1';
};
add_filter( "get_user_option_screen_layout_product", $func, 10, 3 );
0

Your Answer

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

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