Last active
July 18, 2024 02:42
-
-
Save mehrshaddarzi/dfe125aeefb9b0a32c0b953fd4a83c63 to your computer and use it in GitHub Desktop.
wordpress meta box order
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// meta-box-order_toplevel_page_wps_overview_page | |
// metaboxhidden_toplevel_page_wps_overview_page | |
// closedpostboxes_toplevel_page_wps_overview_page | |
// meta-box-order_toplevel_page_wps_overview_page | |
// a:2:{s:4:"side";s:127:"wps_summary_postbox,wps_browsers_postbox,wps_referring_postbox,wps_users_online_postbox,wps_countries_postbox,wps_about_postbox";s:6:"normal";s:160:"wps_hits_postbox,wps_top_visitors_postbox,wps_search_postbox,wps_searched_phrases_postbox,wps_words_postbox,wps_recent_postbox,wps_map_postbox,wps_pages_postbox";} | |
//for dashboard | |
//meta-box-order_dashboard | |
//a:4:{s:6:"normal";s:494:"wp-statistics-quickstats-widget,dashboard_right_now,dashboard_activity,wp-statistics-summary-widget,wp-statistics-browsers-widget,wp-statistics-countries-widget,wp-statistics-hits-widget,wp-statistics-pages-widget,wp-statistics-referring-widget,wp-statistics-searched-phrases-widget,wp-statistics-search-widget,wp-statistics-words-widget,wp-statistics-top-visitors-widget,wp-statistics-recent-widget,wp-statistics-hitsmap-widget,woocommerce_dashboard_recent_reviews,woocommerce_dashboard_status";s:4:"side";s:17:"dashboard_primary";s:7:"column3";s:21:"dashboard_quick_press";s:7:"column4";s:0:"";} | |
// https://developer.wordpress.org/reference/hooks/default_hidden_meta_boxes/ | |
//hide meta box checkbox | |
add_action( 'admin_head', 'remove_wordpress_cfields' ); | |
function remove_wordpress_cfields() { | |
echo '<style>label[for=METABOXIDNAME-hide] { display: none; }</style>'; | |
} | |
add_filter( 'get_user_option_meta-box-order_CPT', 'metabox_order' ); | |
function metabox_order( $order ) { | |
return array( | |
'normal' => join( | |
",", | |
array( // vvv Arrange here as you desire | |
'customdiv-{CPT}', | |
'authordiv', | |
'slugdiv', | |
) | |
), | |
); | |
} | |
# Meta Box Order | |
$meta_box_order = get_user_meta( | |
wp_get_current_user()->ID | |
,sprintf( 'meta-box-order_%s', get_post_type() ) | |
,true | |
); | |
# Hidden Meta Box | |
$meta_box_hidden = get_user_meta( | |
wp_get_current_user()->ID | |
,sprintf( 'metaboxhidden_%s', get_post_type() ) | |
,true | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment