Display hidden post types automatically in WP nav menus admin
One of the most annoying things about WP nav menu admin is when you create a custom post type, you first must go to Screen Options and check the custom post type checkbox to display it for use. Here’s a hack I created to get around this and force the custom post type to display for all users all the time.
function display_post_type_nav_box(){ $hidden_nav_boxes = get_user_option( 'metaboxhidden_nav-menus' ); $post_type = 'foobar'; //Can also be a taxonomy slug $post_type_nav_box = 'add-'.$post_type; if(in_array($post_type_nav_box, $hidden_nav_boxes)): foreach ($hidden_nav_boxes as $i => $nav_box): if($nav_box == $post_type_nav_box) unset($hidden_nav_boxes[$i]); endforeach; update_user_option(get_current_user_id(), 'metaboxhidden_nav-menus', $hidden_nav_boxes); endif; } add_action('admin_init', 'display_post_type_nav_box');