Is it possible to get a container post type menu item with all custom post types inside of it?!

1.All post types
1.1 post type 1
1.2 post type 2
1.3 post type 3
1.4 ect....


Yes you can do that. Use function add_menu_page http://codex.wordpress.org/Function_Reference/add_menu_page to add parent "All post types", then use add_submenu_page http://codex.wordpress.org/Function_Reference/add_submenu_page to add pages to parent page:

    add_action( 'admin_menu', 'my_custom_menu_page' );
    function my_custom_menu_page() {
        $slug = 'all-post';
        add_menu_page( 'All post types', 'All post types', 'edit_posts', $slug, '__return_true' );
        foreach( array( 'post', 'page', 'foo', 'bar' ) as $post_type ) {
            $title = sprintf( 'Post type: %s', $post_type );
            $url = sprintf('/edit.php?post_type=%s', $post_type);
            add_submenu_page( $slug, $title, $title, 'edit_posts', $url );
  • Perfect! That's exactly what i was looking for! :)
    – 2611
    Oct 3 '14 at 13:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.