If you Google “How to use custom post types in WordPress” or “Custom post type Syntax” you will find a ton of results. 2,140,000 to be exact. At least as of 30 seconds ago. Today I’m not going to discuss how to use them but rather how to use them creatively. If you are a developer who is looking for a quick object to register them, I do have one available here click here.
So what the heck is a Custom Post Type? Well, it is the WordPress way of tapping in the Post API. In fact it uses the exact same data structure as a post except changing one column in the database named post_type. That’s right folks! You can literally go into the wp_posts table of your database and change a value in the post_type column and presto! You now have a custom post type. Pages is a built in example of a custom post type. It is worth noting that doing this will only give you custom post type retrieval abilities and non of the admin gui functionality. That is why you should always use the WordPress way. http://codex.wordpress.org/Post_Types.
Ok so know you know what it is. This is why you care:
- WordPress will automatically take care of all of the section and menu generation for you. No more calls to add_menu_page() or add_submenu_page().
- You get to use the existing database table so no custom SQL is needed.
- You may import and export your data easily using the built in export/import tools.
- You get to use about a billion built in functions for interacting with post data.
- Each item gets it’s one WP_Post object (after version 3.5 of course) which is chalked full of goodies.
- Adding meta boxes is a snap.
- Has built in support for things like WYSIWYG editor and featured images
- Saving data, including custom data values, is a snap by using the meta api http://codex.wordpress.org/Metadata_API
- Displaying lists of your items is already built in.
- WordPress will automatically cache your data to reduce database calls.
- Ok……. You get the idea. There are about 99 other good reasons but I don’t want to cause information saturation.
It doesn’t matter wether you’re making a list of addresses or building a custom calendar. Custom posts types can be scaled as large or as small as you need. I have used them for everything from slideshows to tabbed product descriptions. If you know how to work with posts, then you already know how to work with custom post types.