Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I have a group of custom post types such as "CPT A", "CPT B" and "CPT C". I display the admin page for each of these as subpages under a common Admin page.

add_menu_page('Console',
    'Console',
    'plugin_console',
    'plugin',
    array ( $this, 'page_main' ),
    "http://example.com/favicon.ico",
    6
    );

There are also custom taxonomies for the CPTs, and some of them are shared.

What I'm to do is, in the admin pane add submenu page off the main one that links to the taxonomies in edit-tags.php.

add_submenu_page('plugin',
    'Taxonomy',
    'Taxonomy',
    'manage_options',
    'plugin-taxonomy',
    array( $this, 'page_taxonomy' )
    );

The problem I encounter is that the list table doesn't fill. Any suggestions on a good/better approach are most welcome.

Just as a follow up, I want a menu that looks something like:

-Console
--CPT A
--CPT B
--CPT C
--Taxonomy 1
--Taxonomy 2
share|improve this question

1 Answer 1

up vote 0 down vote accepted

We could manipulate the global $menu and $submenu inside the admin_menu hook. But it's easier to let Mike Schinkel's WP Admin Menu Classes take care of it.

require_once('inc/wp-admin-menu-classes.php');

add_action( 'admin_menu', function()
{
    $plugin_page = 'wpse_114343'; 
    add_menu_page(
        'Console',
        'Console',
        'edit_pages',
        $plugin_page,
        function() {},
        "http://cdn.sstatic.net/stackexchange/img/favicon.ico",
        6
    );
    // Move the CPT Movie and remove original
    $cpt = "edit.php?post_type=movie";
    copy_admin_menu_item( $plugin_page,$cpt );
    remove_admin_menu_section( $cpt );

    // Move the CPT Page and remove original
    $cpt2 = "edit.php?post_type=page";
    copy_admin_menu_item( $plugin_page, $cpt2 );
    remove_admin_menu_section( $cpt2 );

    // Move Posts Category and Tags and remove originals
    $cat = "edit-tags.php?taxonomy=category";
    $tag = "edit-tags.php?taxonomy=post_tag";
    $tax_menu = 'edit.php';
    copy_admin_menu_item( $plugin_page, $tax_menu, $cat );
    copy_admin_menu_item( $plugin_page, $tax_menu, $tag );
    remove_admin_menu_item( $tax_menu, $cat );
    remove_admin_menu_item( $tax_menu, $tag );
});

manipulated wp-admin menu and sub-menu

share|improve this answer
    
Wow, that's awesome, thank you! –  Gawain Sep 21 '13 at 11:47

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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