I am desperately looking for some way (any way) to set default “screen options” and metabox order through the functions.php file. does anyone have any help they can provide here?
Leave a Reply
You must be logged in to post a comment.
I am desperately looking for some way (any way) to set default “screen options” and metabox order through the functions.php file. does anyone have any help they can provide here?
You must be logged in to post a comment.
Setting the order of meta boxes on post edit pages
You will need to remove the meta boxes, and add them again in the order you want.
To disable meta boxes: (customize to your needs, look at the metabox id in the html code to know which name you should use as first parameter of the functions)
After removing them, you can use the add_meta_box function to add them at new positions: http://codex.wordpress.org/Function_Reference/add_meta_box. The order of the meta boxes depends on the order in which you call the add_meta_box function. E.g.: with the following code snippet, the comments meta box will be before the custom fields meta box.
You may want to look at the file wp-admin/edit-form-advanced.php
Setting which columns title show up on the post list page
You need to use the filter manage_{$post_type}_posts_columns. E.g.: the following snippet will remove the comments column.
Setting the default results to be shown on the post list page
Use the filters ‘edit_{$post_type}_per_page’ and ‘edit_posts_per_page’.
To target a specific post type:
use
add_filter( 'edit_{post type}_per_page', 'my_edit_post_per_page' );
e.g.add_filter( 'edit_post_per_page', 'my_edit_post_per_page' );
for posts,add_filter( 'edit_page_per_page', 'my_edit_post_per_page' );
for pages.or use a condition within your function. e.g.:
function my_edit_post_per_page( $per_page, $post_type ) {
In the following example, replace
{CPT}
with the post type name, likepost
,page
,book
,event
,imaginary
,foobar
… So if you have a post type namedevent
, you would need to add a filter forget_user_option_meta-box-order_event
.Notes:
normal
, you can also haveside
andadvanced