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'm writing a plugin for work because our main website is being ported to WordPress eventually. I've got multiple custom post types planned for this plugin and would like to group them all into one main menu.

Basically, I want the "Visitors" link to be placed under "Argus Admin". The other links aren't necessary to be added as I can "hack" those wherever I want.

    $v_args = array(
        'labels' => array (
                'name' => 'Visitors',
                'singular_name' => 'Visitor',
                'add_new_item' => 'Register New Visitor', // TODO: http://codex.wordpress.org/Function_Reference/register_post_type#Arguments
            ),
        'public' => true,
        'publicly_queryable' => false,
        'exclude_from_search' => true,
        'show_ui' => true,
        'show_in_menu' => 'argus',  // TODO: This doesn't work...
        'hiearchical' => false,
        'supports' => array( '' ),
        'register_meta_box_cb' => array ( &$this, '_wp_visitor_meta_box_cb' ),
    );

    register_post_type( $post_type, $v_args );

This my menu page that I created:

add_menu_page( 'Argus', 'Argus Admin', 'manage_options', 'argus', array( &$this, '_wp_argus_main_panel' ), '', -1 );
share|improve this question
    
You might also find this link helpful to learn what is currently difficult if not impossible to do with admin menus. –  MikeSchinkel Feb 4 '11 at 7:28
    
I remember stumbling upon that link some time ago. Thanks ;) –  Zack Feb 4 '11 at 15:42
    
Now that wordpress 3.1 is out, where is the documentation for grouping custom post types together? –  Amit Erandole Mar 12 '11 at 18:05

2 Answers 2

up vote 6 down vote accepted

You got it right but you need to wait for WordPress 3.1 where its actually implemented. if you can't wait you can change 'show_in_menu' to false and use add_submenu_page() function define 'argus' as top page and add the Visitors "manually" under Argus Admin menu.

so your code would be:

$v_args = array(
        'labels' => array (
                'name' => 'Visitors',
                'singular_name' => 'Visitor',
                'add_new_item' => 'Register New Visitor',
            ),
        'public' => true,
        'publicly_queryable' => false,
        'exclude_from_search' => true,
        'show_ui' => true,
        'show_in_menu' => 'flase',
        'hiearchical' => false,
        'supports' => array( '' ),
        'register_meta_box_cb' => array ( &$this, '_wp_visitor_meta_box_cb' ),
    );

    register_post_type( $post_type, $v_args );

and then

add_menu_page( 'Argus', 'Argus Admin', 'manage_options', 'argus', array( &$this, '_wp_argus_main_panel' ), '', -1 );
add_submenu_page( argus, 'Visitors', 'Visitors', 'manage_options' , 'visitors' , 'edit.php?post_type=visitors'); 

Hope this Helps

share|improve this answer
    
For now, I think I'll use this feature and then wait for a proper fix @ 3.1. –  Zack Feb 3 '11 at 23:00
    
glad i could help. –  Bainternet Feb 3 '11 at 23:30
    
Is there an in-built solution for this already? –  jilseego Mar 22 '13 at 4:30
    
'show_in_menu' is set to 'flase'. Perhaps you meant false? –  Adam Sack May 21 '13 at 14:21

If this is going to be ported to WordPress eventually (as in, not for another few weeks), I'd suggest waiting for WordPress 3.1 to come out. It's due very soon, and it already does this. Of course, you could skip the waiting and just develop on trunk. The way you're doing it there will should work in 3.1 without any changes.

share|improve this answer
    
Thanks. I'll explore what happens on 3.1 after a few cosmetics I need to do for the rest of the plugin. I'll reserve this as an answer until then. –  Zack Feb 3 '11 at 22:34

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.