Skip to content

Instantly share code, notes, and snippets.

@pimpmywp
Created December 28, 2012 15:02
Show Gist options
  • Save pimpmywp/4398585 to your computer and use it in GitHub Desktop.
Save pimpmywp/4398585 to your computer and use it in GitHub Desktop.
カスタム投稿タイプが多い時に管理画面メニューでの並び順をまとめるスニペット
<?php
add_filter( 'custom_menu_order', '__return_true' );
add_filter( 'menu_order' , 'pm_menu_order' );
function pm_menu_order( $menu_order ) {
$menu = array();
foreach ( $menu_order as $key => $val ) {
if ( 0 === strpos( $val, 'edit.php' ) )
break;
$menu[] = $val;
unset( $menu_order[$key] );
}
foreach ( $menu_order as $key => $val ) {
if ( 0 === strpos( $val, 'edit.php' ) ) {
$menu[] = $val;
unset( $menu_order[$key] );
}
}
return array_merge( $menu, $menu_order );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment