• Hi,

    I’ve been playing with the new post types in 3.0b1 and they’re truly great, really easy to set up and are going to make my life a lot easier. But I need help in trying to manipulate the admin interface.

    If I set up two new post types I’ll get this in the admin menu …

    • Post Type One
    • Add New
    • Edit
    • Post Type Two
    • Add New
    • Edit

    Which is all very well and good, but I need a little more control to produce something like…

    • My Post Types
    • Add New Post Type One
    • Edit Post Type One
    • Add New Post Type Two
    • Edit Post Type Two

    But I can’t seem to find any documentation on how to do this.

    Also, if I turn the ‘show_ui’ in register_post_type to false so that I can use the post type without the admin menu I lose the Publish box from the Add New/Edit Post Type page.

    Any help would be greatly appreciated.

    Thanks!

Viewing 15 replies - 1 through 15 (of 16 total)
  • Moving this to Alpha/Beta forum for now.

    Thread Starter minkowski

    (@minkowski)

    Giving this a little bump as I remember something.

    I vaguely remember some documentation or an example of adding post types to WordPress earlier than 3.0 but I have had no luck finding it again.

    I don’t remember the details of the code but it may help me solve thins problem. Does anyone know where that may have been?

    Are you thinking of something like the Custom Post Type UI plugin?

    Thread Starter minkowski

    (@minkowski)

    No, I can build the post types manually, it’s just a matter of organising the admin interface the way I’d like it. I may download the Custom Post Type UI plugin and dissect it but I really need to get my head around creating an admin interface.

    Thread Starter minkowski

    (@minkowski)

    If I use the register_post_types function a new top level menu item is built for me automatically. This appears at the bottom of the top part of the menu beneath Comments by default.

    If I try to make a new top level item in the top section of the menu manually, all I seem to be able to do is create a subpage to an existing type.

    add_posts_page adds a new page beneath Posts, add_pages_page add a new page beneath Pages, etc.

    The problem is that I want to place a new top level menu item within this top part of the menu manually so I can build in all of the subpages manually.

    The problem I’m having is simply cosmetic to the admin interface as I just want to reorder things, I just don’t know how.

    +1 searching for same answer to above questions.

    Probably has to do with $menu global mods, but beyond that I am no help yet.

    I would also find this very useful. Another thing I’d like to see is to be able to group my custom post types together, to seprate them from the WordPress built-in content types block.
    What I mean, is in the admin menu, after Comments, there is a separator, and after that comes Appereance etc…
    I’d like to be able to create a separator like that.

    Thread Starter minkowski

    (@minkowski)

    I’ve just encountered this issue again. I just ignored it last time and had a stack of different post types in the admin menu, but if I can get it sorted this time I’ll be a lot happier with the result.

    So, anyone know?

    Thread Starter minkowski

    (@minkowski)

    In fact, I want it to look more like this.

    • Taxonomy Name (link to wherever I like)
    • View/Edit Post Type A
    • Add Post Type A
    • View/Edit Post Type B
    • Add Post Type B
    • View/Edit Taxonomy

    Been looking around for something down this line myself. I see where you can add a sub menu under your custom post type but I want my custom post type under my own main menu page.

    Found this in the codex.

    Here’s an example of adding an option page under a custom post type menu block:

    <?php add_submenu_page('edit.php?post_type=wiki', 'Options', 'Options', 'manage_options', 'wiki-options', array(&$this, 'options_page') ); ?>

    but that goes the opposite way I need it.

    Thread Starter minkowski

    (@minkowski)

    I’ve written menus like that in the past, and it’s very useful, but I don’t think I can apply this technique to altering menus that were already created. I did try Adding one like this and then setting the show_ui parameter to false in the register_post_type function but that just removes everything and I can’t access the page even via a direct link.

    What I did find was a plugin called Admin Menu Editor that will do everything I need, but it’s still something that I would prefer to code in myself. I reckon I’m going to have to take the code apart in that plugin and see how they did it there.

    Thanks for looking though!

    Read thru the Adding_Administration_Menus again and paid attention to this

    function
    The function that displays the page content for the menu page.

    Technically, as in the add_menu_page function, the function parameter is optional, but if it is not supplied, then WordPress will basically assume that including the PHP file will generate the administration screen, without calling a function. Most plugin authors choose to put the page-generating code in a function within their main plugin file.

    Played around a little and got this to work

    add_object_page('My Shop', 'My Shop', 'manage_options', 'my-shop-order-log', '', MS_PLUGIN_URL . '/images/ms_icon.png');
        add_submenu_page('my-shop-order-log', 'Products', 'Products', 'manage_options', 'edit.php?post_type=ms_product');
        add_submenu_page('my-shop-order-log', 'Add New Products', 'Add New Products', 'manage_options', 'post-new.php?post_type=ms_product');
        add_submenu_page('my-shop-order-log', 'Categories', 'Categories', 'manage_options', 'edit-tags.php?taxonomy=category&post_type=ms_product');
        add_submenu_page('my-shop-order-log', 'Settings', 'Settings', 'manage_options', 'my-shop-settings', 'my_shop_setting');

    Now if I can just turn of the post ui without shutting this down it will work fine

    Minkowski, have you tried something down this line?

    Use add_menu_page to add the top level menu. Use this as an arg for register_post_type():
    show_in_menu => $parent
    where $parent is the top level menu.

    Can’t seem to wrap my self around this one

    function ms_create_post_type() {
        register_post_type('ms_product', array(
       ....
        'show_ui' => true,
        'show_in_menu' => false,
       ....
        ));
    }

    should take ms-product out of a menu, right?
    And

    add_action('admin_menu', 'ms_create_admin_menu');
    function ms_create_admin_menu() {
        add_menu_page('My Shop', 'My Shop', 'manage_options', 'my-shop', 'my_shop_order_log', MS_PLUGIN_URL . '/images/ms_icon.png');
    }
    
    add_action( 'init', 'ms_create_post_type' );
    function ms_create_post_type() {
        register_post_type('ms_product', array(
       ....
        'show_ui' => true,
        'show_in_menu' => 'my-shop',
       ....
        ));
    }

    should put ms-product under my custom menu?
    Or do I not understand $parent?

    Are you using the 3.1 beta?

Viewing 15 replies - 1 through 15 (of 16 total)
  • The topic ‘Admin Interface and Post Types’ is closed to new replies.