Ask your WordPress questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

Move Publish MetaBox to Bottom WordPress

  • SOLVED

Ok, I have a custom post type I wrote.

I want to move the "Publish MetaBox" to the bottom under the editor and extend the editor to full width to fill in the blank space.

I don't want a plugin, I need to know what to add to the functions.php to accomplish this.

Thank you.

Answers (2)

2011-08-12

Ivaylo Draganov answers:

Hi,

these threads form StackExchange and Wordpress.org forums might be usefull for you:
[[LINK href="http://wordpress.stackexchange.com/questions/4552/how-do-i-force-a-single-column-layout-in-screen-layout"]]http://wordpress.stackexchange.com/questions/4552/how-do-i-force-a-single-column-layout-in-screen-layout[[/LINK]]
[[LINK href="http://wordpress.org/support/topic/set-screen-layout-number-of-columns-to-default-1-column?replies=2"]]http://wordpress.org/support/topic/set-screen-layout-number-of-columns-to-default-1-column?replies=2[[/LINK]]


Ivaylo Draganov comments:

I played around with these settings - it's all in the usermeta. There three fields that need to be set in order to force one column. The fields are 'screen_layout_post', 'metaboxhidden_post' and 'meta-box-order_post'. Putting the following code in your functions.php would force a one column layout:
[[LINK href="http://pastebin.com/wPktB5J0"]]http://pastebin.com/wPktB5J0[[/LINK]]

This will *almost* get you there. I say almost, because this code forces the changes on every pageload. Some kind of advanced check of the initial values has to be made so that user would be able to customize the order of boxes and to toggle their visibility.

I'll think about it. Maybe I manage to crack it :--)

Please let me know how that code worked for you.


Ivaylo Draganov comments:

Please read the comments in the code to understand how it works and how to customize it. Now it is set to show only the editor and the publish box - tags, categories, etc. will be hidden.

If you don't understand PHP code feel free to ask :--)


Ivaylo Draganov comments:

Here's and updated version of the code:
[[LINK href="http://pastebin.com/yK6C20gC"]]http://pastebin.com/yK6C20gC[[/LINK]]

This version will change the layout only for new users or for users that have never changed the default layout of the boxes (never touched the "Screen options" tab or dragged any boxes around).

I'd suggest you run a combo of the two versions:
* the first version for some time to force the changes for all users
* then the second version to set the defaults for new users and to allow existing users to change the layout

Cheers! I hope that this is what you were after.


Armand Morin comments:

the first version worked. Thanks.

FYI, I had to add this line above the code to get it to work.

require(ABSPATH . WPINC . '/pluggable.php');

This has to be placed before get_currentuserinfo(); or it won't work because that information is not available until pluggable.php is called.

2011-08-12

Maor Barazany answers:

In the options window on top of page you may select how many columns you want - you just have to set to 1 column instead of 2, and the editor will be full width


Armand Morin comments:

I'm looking to automate this programatically. I want people who use this to have the page set this way be default.


Maor Barazany comments:

Add this to your functions.php and you will have it automatically


function tc_screen_layout_columns( $columns ) {
$columns['post'] = 1;
return $columns;
}
add_filter( 'screen_layout_columns', 'tc_screen_layout_columns' );

function tc_screen_layout_post() {
return 1;
}
add_filter( 'get_user_option_screen_layout_post', 'tc_screen_layout_post' );


Maor Barazany comments:

I've noticed you want this to a CPT and not the regular post type.
So in this case, suppose your CPT name is <em>mycustom</em>, so the function will look like this:



function tc_screen_layout_columns( $columns ) {
$columns['mycustom'] = 1;
return $columns;
}

add_filter( 'screen_layout_columns', 'tc_screen_layout_columns' );


function tc_screen_layout_mycustom() {
return 1;
}

add_filter( 'get_user_option_screen_layout_mycustom', 'tc_screen_layout_mycustom' );


Armand Morin comments:

Thanks, I assumed those changes would have to be made. The problem now is the "Publish" Metabox dissappeared. It doesn't make sense that it would, but it does.

Any ideas?


Maor Barazany comments:

It is very weird and does not make sense. I've just used my code in a dev site, but my publish metabox is still there at the bottom...


Armand Morin comments:

hmmm... did you use with a CPT?


Maor Barazany comments:

You're right, on a CPT the publish metabox disappear, on a page or post it's not.
But, if I move the publish metabox to the wider column and only then add the filter, it stays there. I assume it is a sort of a bug, I think it can be solved maybe with adding the publish metabox again in the code also.


Maor Barazany comments:

I checked it again, well, it is not disabled, it is just hidden in css for some reason.
Look with firebug for div with class <em>inner-sidebar</em>
You may "play" a bit with css and apply custom css to your admin area in order to display the narrow column as well.