Change the Menu Icon and Position of Any Post Type
Gives a post type registered by a plugin or theme a different Dashicon and moves it up or down the admin menu.
Opens WPIDE on
Code
// Post type => icon and menu position.
$wpide_menu_tweaks = array(
'portfolio' => array( 'icon' => 'dashicons-art', 'position' => 6 ),
);
add_filter( 'register_post_type_args', function ( $args, $post_type ) use ( $wpide_menu_tweaks ) {
if ( isset( $wpide_menu_tweaks[ $post_type ] ) ) {
$args['menu_icon'] = $wpide_menu_tweaks[ $post_type ]['icon'];
$args['menu_position'] = (int) $wpide_menu_tweaks[ $post_type ]['position'];
}
return $args;
}, 10, 2 );
Notes
Pick icons at developer.wordpress.org/resource/dashicons. Positions: 5 below Posts, 20 below Pages, 60 below Appearance.
How to add this snippet
- Install WPIDE on your WordPress site (it is free) and open Code Snippets.
- Use snippet above adds it from the library in one click. Or copy the code into a new snippet with the same code type.
- It is added inactive: review the code and settings, then switch it on.