[wp-hackers] Custom Post - implementation specifics

Mike Schinkel mikeschinkel at newclarity.net
Sat Dec 5 17:59:29 UTC 2009


On Dec 5, 2009, at 2:52 AM, Ptah Dunbar wrote:
> To quote Stephen:
> 
>> In a way it's a shame that in Admin we moved away from "Action" ("Write". "Edit") menus toward "Thing" ("Posts", "Pages") menus, as this makes it more difficult -- or at least more bulky -- to incorporate custom post types.  Where previously it would have been intuitive to add a new item or two under "Edit", now to follow the existing structure it would be a case of adding a whole new top menu for each new Post Type, which would get big pretty quickly.
> 
> After custom post types becomes mainstream once 2.9 ships, people are going to face the hassle of creating admin menus for them. Going back towards the "Action" type menus will make things A LOT more simpler and consistent with the WordPress publishing experience. Users wouldn't have to think twice about which menu they need to click on to publish content to. They would just click under "Write", and available post types will be presented as submenu items. This is a major prerequisite before any administrative features for custom post types begin.

My first reaction is that going back to Action will add complexity to the default use case for blogging, i.e. to work with Posts.  

It's also the approach that Drupal takes and is one that I always found to be challenging for end users when they wanted to add new content because they usually seemed to be looking for a menu related to what they wanted to add (i.e. a Post or a Product) instead of looking for a generic menu option. Drupal also throws up a list of content types which adds a click and page reload to adding new content.

> I think there's a significance difference between adding a custom plugin page using the menu/ settings API, compared to adding an administrative page for post types. Reverting back to the old "Action" type menus makes the writing and editing experience for any post type consistent with the admin and a lot more scalable. Developers really only need to customize admin elements belonging to their post type's write page.

While I don't have an extremely strong view against Actions menus I'd suggest considering instead having an API that would add a new top level admin menu for each new custom content type.  For example, I could see "Members" and "Companies" as being two top level admin menus. 

And having their own admin menus could be useful because each content-type could easily have special admin options, i.e. Members could have "Interests" and "Purchases" options and Companies could have a "Contacts" and "Products" options. (Please don't fixate on my examples and debate what WordPress is appropriate for; they were just hypothetical examples.)

> If that's too much abstraction, then consider:
> 
> register_post_type( 'articles', array( 'admin' => 'Articles');
> 
> Which just creates the write and edit submenus for the Articles post type, and the developer would need to call the necessary add_meta_box() functions for their page elements on the write page.

I would lean toward something like that, yes.

Further, I think it would also be ideal to be able to remove both the Post and the Page admin options as well as combine any post types into a single admin menu/edit list.  This would give the person setting up a site and/or a plugin full flexibility and to configure a content creation environment that works how they best need and would even let them approximate the approach you suggest above if that is really what they want.

(And while we are add it, can we tackle one of my pet peeves?  Can we change the "Edit" link in the Post and Page admin menus to be "List", or at least "List/Edit?"  Every single time I use WordPress I have to do a mental translation from "Edit" to "List" and vice versa. :-)

> All in all, adding administrative features for custom post types should be dead simple. The developer shouldn't have to do the same work required to create custom plugin pages (using the menu API, settings API, handling option sanitizing, etc.) as those are two distinct administrative task.

100% agreed.

What's more, minimally I think it would be really a good idea in 2.9 to have an "Post Types" link under the Settings menu that lets user add new post types with nothing more (to start) then just a way to add new types names and see a list of those names.  In combination, I think having a list of known types for a given site stored in wp_options is really important.

-Mike Schinkel


More information about the wp-hackers mailing list